nodebrewをインストールしようとした際にパス設定でつまづいたのでその時の備忘録です。
1.やったこと
前提環境:
MacOS Catalina 10.15.7
homebrew導入済み
1.nodebrewをインストール
brew install nodebrew
2.環境変数を追加
bash_profileファイルに以下の通り環境変数を追加してパスを通した
export PATH=$HOME/.nodebrew/current/bin:$PATH
3.bash_profileを読み直して設定反映
source ~/.bash_profile
4.nodebrewで使用するディレクトリセットアップ
nodebrew setup
5.最新版nodeのインストール
nodebrew install latest
2.問題
nodebrew, nodeはインストールできているのにnodeコマンドが使えない。。。
3.原因
MacOS Catalinaからは、デフォルトのシェルスクリプトがbashからzshになったため、bash_profileではなくzshの設定ファイルに環境変数を追加する必要があった
※以下コマンドで現在使用しているシェルスクリプトの種類を確認することができる
echo $SHELL
4.解決法
1.bash_profileではなくzshrc
ファイルに設定を追加
export PATH=$HOME/.nodebrew/current/bin:$PATH
2.zshを読み直して設定反映
source ~/.zshrc
まとめ
シェルスクリプトの種類などあまり意識せず使用していましたが、注意しないといけないなと思いました。