LoginSignup
43
40

More than 5 years have passed since last update.

node.js をアップデートしたら、npm でエラー

Last updated at Posted at 2015-10-06

nodist で久々に(!)node.js のアップデートをしようとしたら、nodistのバージョンが古かったようで、nodist最新版にごそっと入れ替え。
⇒ nodist update でこんなエラーが出たら...

無事 node.jsも最新版(stable ver.4.0.0)になったと思ったら、今度は npm でエラー。。。
Mac だとこんなエラー地獄にはならないのだろうか。さすがにうんざり。
npm コマンド全般が使えなくなっている感じ。

> npm -v
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\nodist\bin\node_modules\npm\node_modules\npmlog\log.js:2:16)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

なんかモジュールがないよと怒られている模様。
ダメ元で

> npm install are-we-there-yet

なんてやっても同じエラーで怒られる。

検索したら同じエラーで困っている人発見!
⇒ npm doesnt work, get always this error -> Error: Cannot find module 'are-we-there-yet'

npm が壊れているらしい。npm だけ再インストールした方がいいよと。

(1) グローバル node_modules ディレクトリに移動

> cd /nodist/bin/node_modules

(2) npm ディレクトリを削除(もしくはどこかへ避難がいいね)
(3) 最新版をダウンロード ⇒ GitHub - npm
(4) (1)のディレクトリ内の npm の中身をごそっと入れ替え
(5) npm のバージョン確認

> npm -v
3.3.6

(6) 念のため最新バージョンの確認を

> npm update -g npm

これでエラーも出なくなり、npm が使えるようになった!

ちなみに、こんなコマンドもあるらしい。
⇒ 【Node.js】足りないモジュールをたったの一行でインストールするコマンド

> npm install -g npm-install-missing
> npm-install-missing
43
40
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
43
40