You have $NVM_DIR set to “/Users/yourname/.nvm”, but that directory does not exist. の解決方法
nvm がインストールできなくて You have $NVM_DIR set to “/Users/yourname/.nvm”, but that directory does not exist. というメッセージが表示される問題を解決する方法をご紹介します。
問題) nvm がインストールできない
Install & Update script | creationix/nvm: Node Version Manager より、以下のように nvm インストールスクリプトを実行しても You have $NVM_DIR set to “/Users/yourname/.nvm”, but that directory does not exist. Check your profile files and environment. というメッセージが表示されてインストールされませんでした。
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13226 100 13226 0 0 113k 0 --:--:-- --:--:-- --:--:-- 114k You have $NVM_DIR set to "/Users/yourname/.nvm", but that directory does not exist. Check your profile files and environment. |
原因) 環境変数 NVM_DIR
環境変数 NVM_DIR に値がセットされているのが原因でした。
$ echo $NVM_DIR /Users/yourname/.nvm |
解決方法) 環境変数 NVM_DIR を空に
環境変数 NVM_DIR を空にします。
NVM_DIR= |
$ echo $NVM_DIR |
再度、nvm インストールスクリプトを実行したところ無事に nvm をインストールできました。
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13226 100 13226 0 0 52131 0 --:--:-- --:--:-- --:--:-- 52276 => Downloading nvm from git to '/Users/yourname/.nvm' => Cloning into '/Users/yourname/.nvm'... remote: Enumerating objects: 278, done. remote: Counting objects: 100% (278/278), done. remote: Compressing objects: 100% (249/249), done. remote: Total 278 (delta 33), reused 93 (delta 16), pack-reused 0 Receiving objects: 100% (278/278), 142.36 KiB | 24.00 KiB/s, done. Resolving deltas: 100% (33/33), done. => Compressing and cleaning up git repository => Appending nvm source string to /Users/yourname/.zshrc => Appending bash_completion source string to /Users/yourname/.zshrc => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion |
以上、nvm がインストールできなくて困った、現場からお送りしました。