LoginSignup
3
1

More than 3 years have passed since last update.

Node.jsのバージョンを切り替えてnode -vしてもバージョンが切り替わっていない!

Last updated at Posted at 2020-07-04

Node.jsのバージョン切り替えで詰まった話。

バージョンを設定して、確認すると

terminal
$nodebrew use v12.18.2

$nodebrew ls
v10.16.3
v12.4.0
v12.18.2
v14.5.0

current: v12.18.2 // nodebrewでは選択されている

順調っ!

terminal
$node -v
v10.16.3

あれっ?設定されていない?
環境変数PATHに設定されているディレクトリを確認してみる。

terminal
$which node
/usr/local/bin/node ← Systemのnode
  • システムのnodeを参照していることが原因だった

解決法

環境変数を追加

/.bash_profile
...
export PATH=$HOME/.nodebrew/current/bin:$PATH
terminal
$source ~/.bash_profile

$which node
/Users/macuser/.nodebrew/current/bin/node ←nodebrewが適用されている

$node -v
v12.18.2

できた!!

3
1
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
3
1