Node.jsのバージョン切り替えで詰まった話。
バージョンを設定して、確認すると
terminal
$nodebrew use v12.18.2
$nodebrew lsv10.16.3
v12.4.0
v12.18.2
v14.5.0
current: v12.18.2 // nodebrewでは選択されている
順調っ!
terminal
$node -vv10.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 -vv12.18.2