I am unable to install nvm
on my Mac. I have installed Node.js and it's running perfectly fine but unable to install nvm
on my system.
While checking Node version it's showing:
$ node -v
v21.3.0
but when I try to check nvm
version it gives me an error:
$ nvm -v
zsh: command not found: nvm
When I try to install nvm
it gives me an error :
$ brew install nvm
Warning: nvm 0.39.5 is already installed and up-to-date.
To reinstall 0.39.5, run:
brew reinstall nvm
To resolve this issue, ensure that nvm is properly set up in your shell configuration. Since you are using zsh, add the following lines to your .zshrc file:
brew upgrade
brew install nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix nvm)/etc/bash_completion.d/nvm"' >> ~/.zshrc
source ~/.zshrc
After running these commands, nvm should be set up correctly. You can verify the installation by checking the nvm version:
$ nvm --version
Looking at the warning which you added in your question, I surmise that nvm
is installed on your machine but may not have been setup properly. Nevertheless, adding full steps for you to verify which one you missed and fix the same.
nvm
is installedBefore making changes, check if nvm
exists:
# confirm nvm is installed
$ brew list | grep nvm
# if the above doesn't return anything, install nvm
$ brew install nvm
Sometimes Homebrew issues prevent nvm
from working properly. For that run:
$ brew doctor
# If you see any warnings, follow the suggested fixes and
# rerun brew doctor until everything looks good.
nvm
directory (if missing)$ mkdir -p ~/.nvm
nvm
to your shell configurationManually add these lines to ~/.zshrc
:
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix nvm)/nvm.sh" ] && . "$(brew --prefix nvm)/nvm.sh"
[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && . "$(brew --prefix nvm)/etc/bash_completion.d/nvm"
Save the file and reload the configuration:
$ source ~/.zshrc
Check if nvm
is now working:
$ nvm -v
If you still get an error, restart your terminal and try again. Sometimes failing to do this might also lead to issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With