0
0

More than 1 year has passed since last update.

作業ディレクトリ依存のnodeバージョン確保する

Last updated at Posted at 2022-10-08

※手順はMacでzshを想定

direnvのインストール

brew install direnv

.zshrcに以下を追加

~/.zshrc
eval "$(direnv hook zsh)"

nvmのインストール

brew install nvm
~/.zshrc
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

「source ~/.zshrc」を忘れずに

環境を保持したいディレクトリこのファイルを作る

.envrc
__=`pwd`
export NVM_DIR=$__/.nvm
if ! [[ -d $NVM_DIR ]];
then
  mkdir $NVM_DIR
fi
source $(brew --prefix nvm)/nvm.sh

direnv: error /Users/pooh/Workshop/ibushigin/code/ibushigin-gohe_2/.envrc is blocked. Run `direnv allow` to approve its content

このエラーが出たらあせらずdirenv allowを実行

経緯

他の作業環境のglobal汚染やnodeバージョンをあやまって削除したなど混乱生じてたので
ディレクトリ依存でnodeのバージョン管理できるものを探したが見つからなかった。もっとマシな解決法があったら紹介してほしい

検索用

ディレクトリーごとに フォルダーごとに nodeのバージョン管理

0
0
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
0
0