「NPM」カテゴリーアーカイブ

【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」

json-serverでwatchしたらこのようなエラーがでてDHCで404などが帰ってくる場合。
下のようにエラーでる。

【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」
【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」

他に同じportでlocalサーバー立てていないか確認してください。

gulpやなんやらでbrowser-snycでlocal:3000をすでに使っているのに、
json-serverでlocal:3000にアクセスしているけーすがあります。

brower-snycの方の設定を変えてしまいましょう。
下記は1例です
browser-snycはデフォルト3000らしいです。
ドキュメント
のでそれを変更。
[code language="javascript"]
var browser = require("browser-sync");
gulp.task("server",function(){
browser({
server:{
baseDir: "./"
},
url: {
port: 3001
},
port: 8080
});
});
[/code]

もう一回gulpもjson-serverも立ち上げて、

【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」
【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」

DHCも

【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」
【json-server-watch db.json】エラー「events.js:154 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE 0.0.0.0:3000」

無事リクエストが返ってきました。

でわーーーー

【Error】node-sassが怪しい | fs.js:856 return binding.readdir(pathModule._makeLong(path));でたら

久しぶりに動かしたプロジェクトでgulp叩いたらエラー出てた。
fs.js:856 return binding.readdir(pathModule._makeLong(path));
スタックトレース追っていったらnode-sassとかから出ているみたい。

ここ参考に、
やっていることはインストールしなおしているようなので、依存関係おかしくなっているのかな。。

npm i -D node-sass

tslintもエラー出てたら
npm i -D tslint

動いた。
これから腕まくりします。

でわーーーーーーーー

【TypeScript】sh: tsc: command not found (npm run build時)

npm run buildした際にこういうのでたら

sh: tsc: command not found

▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "run" "tsc"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! an2_ts_playgrond@1.0.0 tsc: `tsc -p .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the an2_ts_playgrond@1.0.0 tsc script 'tsc -p .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the an2_ts_playgrond package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc -p .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs an2_ts_playgrond
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls an2_ts_playgrond
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! /Users/No51/Desktop/Git/angu2_type/an2_ts_playgrond/npm-debug.log
▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! an2_ts_playgrond@1.0.0 build: `npm run tsc && npm run browserify`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the an2_ts_playgrond@1.0.0 build script 'npm run tsc && npm run browserify'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the an2_ts_playgrond package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run tsc && npm run browserify
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs an2_ts_playgrond
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls an2_ts_playgrond
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! /Users/No51/Desktop/Git/angu2_type/an2_ts_playgrond/npm-debug.log
[an2_ts_playgrond]

--------------------------

sh: tsc: command not found

これ。
tscがコマンドでパス通っていない可能性大
npm install tsc

をやってみてください。
npm のグローバルのパスが通っていればうまくいくはずです。

【npm】npm i でpackageのバージョン指定、上げたくない時

npm i で勝手にバージョン上勝手しまうことがあります。
それは
package.jsonのバージョン指定が

fafafa : ^2.5.0

とかになっているからです。
この場合もし2.5.1とかバージョンが上がったら
npm installで上がってしまいます。

もしnpm i でpackageのバージョン指定、上げたくない時

npm install --save --save-exact [packagName]

とやるといいです、

npm config ls -l
とやってみてください。
npm の設定が見れます。

【npm】npm i でpackageのバージョン指定、上げたくない時
【npm】npm i でpackageのバージョン指定、上げたくない時

そこに書いてある
save=true
save-exact=true

はnpm i 時に自動でそれをオプションなしでやってくれます。
もしfalseになっていたら

ターミナルで
npm config set save=true
npm config set save-exact=true

をしてください。
npm config ls -l
でtrueになったことを確認してください。

これでオプションなしで、表題のことをやってくれます。

でわまたー