11

I installed nvm via homebrew, but when I run nvm -v or nvm --version form terminal I receive the message command not found: nvm. When I look in finder and cmd+shift+. I can see the ~/.nvm folder.

Initially I did not have a .bash_profile in my user directory, so I added one and the command to recognize nvm per this post: Brew install nvm. nvm: command not found

However, that did not resolve the issue. I've not had this issue with an nvm install before, What could be going on here?

I am on macOS Catalina 10.15.6

kdub1312
  • 803
  • 2
  • 9
  • 19

2 Answers2

39

I was facing the same issue after installing nvm. Whenever my iTerm / terminal restarts, nvm is gone.

Steps I followed to make it work.

After installing it, update the Homebrew package list and install NVM.

brew update
brew install nvm

Next, create a directory for NVM.

mkdir ~/.nvm

Now add these lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later)

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

Echoing $NVM_DIR should now return your NVM directory

:$ echo $NVM_DIR
/Users/username/.nvm

Now running nvm -v should return nvm’s options. To see what Node versions are available to install run:

nvm ls-remote

For me, I just needed the latest point release of Node version 11 so I ran

nvm install 11

After installing you can verify what is installed with

nvm ls

If you have multiple versions and you want to specify which version you would like to use, simply use:

nvm use 11

to use Node version 11. Switching back to, let’s say, version 12 would be as easy as nvm use 12. After switching to node version 11, all my packages installed properly.

Aswath
  • 811
  • 7
  • 20
5

For my scenario, I was able to fix by uninstalling nvm and then reinstalling via curl, which seems to have worked.

I also created a .zshrc file, which apparently mac OS 10.15 and up needs.

I used the documentation here to uninstall and reinstall: https://github.com/nvm-sh/nvm#about

.zshrc requirement:

https://github.com/nvm-sh/nvm#troubleshooting-on-macos

The steps I took:

  1. From terminal, run
rm -fr "$NVM_DIR" 
  1. Then on the same terminal, run
touch ~/.zshrc

to create a .zshrc file.

  1. Now run
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  1. Finally, run
~/.nvm/nvm.sh
Brandy Carney
  • 1,186
  • 10
  • 21
kdub1312
  • 803
  • 2
  • 9
  • 19