LoginSignup
24
14

More than 5 years have passed since last update.

Node.js のバージョンが変わらなくてイラッとしたときの解消法

Posted at

事象

npm WARN npm npm does not support Node.js v7.6.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

と注意されるようになったので、
nodeをupdateしようと決意。
どうやら n というのがいいらしい、とグーグル先生が教えてくれたので、

npm install -g n
n --latest
sudo n latest

とやってみたら、

 install : node-v10.5.0
       mkdir : /usr/local/n/versions/node/10.5.0
       fetch : https://nodejs.org/dist/v10.5.0/node-v10.5.0-darwin-x64.tar.gz
############################### 100.0%
   installed : v7.6.0

あれ?

node --version
v7.6.0

なんでだよ!
ってなった

原因

$ which node
/Users/HOGE/.nvm/versions/node/v7.6.0/bin/node

どうやらnvmの方のnodeみてるよう設定されてたので、 n でnodeいれても
それが適用されていなかった
そもそもnvmって(Node Version Manager)だから、間違いないのかもだけどw
n のほうがなんかわかりやすかったからnvmから離脱したい

解決法

1 .bash_profileから 「nvm読むぜ」の記載削除
2 .bash_profile更新
3 .nvmフォルダの削除
4 node の場所と、バージョンがあがったこと確認して完了

1 .bash_profileから 「nvm読むぜ」の記載削除

1 .bash_profileから 「nvm読むぜ」の記載削除
ターミナルにて

$ vi ~/.bash_profile
i

して

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

上記削除する

escキー
:
wq

して編集完了する

2 .bash_profile更新

.bash_profile の変更を反映

source ~/.bash_profile

3 .nvmフォルダの削除

$ sudo rm -rf ~/.nvm

4 node の場所と、バージョンがあがったこと確認して完了

$ which node
/usr/local/bin/node
$ node --version
v10.4.1

ニッコリ。


参考にした記事

※ nodebrewってのも良いらしいです〜

@kota2_0 さんの記事
Node.jsの管理をnvmからnodebrewに変更した時のメモ

24
14
1

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
24
14