Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh: command not found: nvm

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

like image 882
Saggitarie Avatar asked Jul 16 '26 01:07

Saggitarie


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!
like image 95
orlovvvv Avatar answered Jul 17 '26 15:07

orlovvvv


I also had the same issue after installing nvm and tried to run nvm command in VS Code terminal. This is how I solve it:

Prerequisites:

  • macOS Sonoma v14.0
  • already install Homebrew (mine is v4.1.14)

Steps:

  • Right after installing nvm with brew, create a .nvm folder mkdir .nvm
  • Create a .zshrc file in Home directory, same as .nvm
  • Open and add this code below to the .zshrc file

source $(brew --prefix nvm)/nvm.sh

  • Back to terminal, execute the .zshrc by running source ~/.zshrc
  • Restart the VS Code and try to run a nvm command

May this help you!

like image 28
syhrimr Avatar answered Jul 17 '26 14:07

syhrimr