Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayakawatomoaki/d5ccb508cb897bf9c6f6 to your computer and use it in GitHub Desktop.
Save hayakawatomoaki/d5ccb508cb897bf9c6f6 to your computer and use it in GitHub Desktop.
npmで「env: node: No such file or directory」とエラーが出たときの対応
$ npm -v
module.js:338
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:18:11
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:86:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
// もともとinstallされているnode,npm残骸が悪さをしているので削除
$ sudo rm -rf /usr/local/lib/node_modules
// 削除されたことを確認
$ npm -v
-bash: /usr/local/bin/npm: No such file or directory
// npmを再インスト
$ curl -0 -L http://npmjs.org/install.sh | sudo sh
// パスを通す
$ echo ‘export PATH=$PATH:~/.nodebrew/current/bin:~/.nodebrew/current/lib/node_modules/npm/bin’ >>
~/.bashrc
$ source ~/.bashrc
$ npm -v
2.10.0
@pogin503
Copy link

👍
HomebrewのNode.jsを削除してもnvmの方のnodeを読みにいってくれなかったので
sudo rm -rf /usr/local/lib/node_modules
をしたら読みにいくようになりました。

@nitaking
Copy link

👍

@sudokzt
Copy link

sudokzt commented Jul 1, 2020

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment