LoginSignup
41
35

More than 5 years have passed since last update.

npm command not found と出てきた時の解決方法

Last updated at Posted at 2015-10-17

npmを使ってgulpのプラグインをインストールしようとしたら、

command
npm command not found

と出てきて、??? となったので一応メモ。
同じようなケースの解決方法があまり見つからなかったので色々調べてから作業を始めたんですけど、Node.js を再インストールしたら、すんなり npm が動くようになりました。

せっかくなので nodebrew もインストール

参考にさせてもらったサイト(下のサイト)が、nodebrew をインストールするために node を再インストールする方法を紹介していたので、せっかくなので node を再インストールしながら nodebrew も一緒にインストールしてみました。
node.jsのversionを管理するためにnodebrewを利用する

ほとんど上のページで紹介されているコマンドを打っていけばすんなり行ったので、一部追加の作業の部分だけメモってます。

.bash_profile を作成

nodebrew のパスを通すときに .bash_profile が見当たらなかったので、下のサイトを見ながら、ホームに.bash_profile を作成。
macで.bash_profileの場所が見つからないときは
あとはパスを通して nodebrew のバージョンを確認すれば nodebrew はインストール完了。

command
$ source ~/.bash_profile
$ nodebrew help

Node.js をインストール

次に node をインストールしていくんですが、node のバージョンは、下のサイトで確認しました。
Nodejs 日本ユーザーグループ

このメモを書いた時点の安定版は v 0.10.12 だったので、これをインストール。

command
$ nodebrew install-binary v0.10.12

これで npm もインストールできました。

command
$ npm -v
1.4.3
41
35
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
41
35