zsh: command not found: nvm

Viewed 2752

Recently, I've been trying to use nvm to manage node version. I successfully installed nvm on Mac OS Catalina(10.15.6) and I can switch between version from the terminal.

However, if I try to do the same thing with the integrated terminal on VSCode, I get zsh: command not found: nvm

Been looking for solutions or workaround, but there seems to be no relevant answers. Has anyone figure this out?

Thanks in Advance

2 Answers

When I installed VSCode, oh-my-zsh and NVM using homebrew I had the same issue. It appears to put wrong paths in ~/.zshrc (might be the same for bash).

Solution:

  1. Open ~/.zshrc or ~/.bashrc
  2. Create a backup of that file in case something goes wrong
  3. Compare paths under the line

export NVM_DIR="$HOME/.nvm"

  1. Now you need to fix the two paths if different than those below

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

  1. Type source ~/.zshrc or source ~/.bashrc in terminal depending on what you use.
  2. Restart VSCode built-in terminal and see if that helped. Good luck!

I figured this out so I'll post an answer.

  • BTW I'm a Mac user. Not really sure about windows.

The reason why I get the zsh: command not found error was because I had Visual Studio Code placed under the Documents directory.

It seems like VSCODE terminal works properly when it is set under the Applications folder.

Make sure to place VSCode under Application folder.

Related