DEV Community

Ziyi Chu
Ziyi Chu

Posted on

Command nvm not found and Command node not found after already installed nvm on MacOS?

Why do we see these types of errors?

Command nvm not found
Command node not found
Enter fullscreen mode Exit fullscreen mode

Because we didn't add the source lines to the correct shell startup script, that is, ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc, depending on the shell program you are using.

How do you find these startup scripts?

These files that begin with a "." are usually hidden, so you can't find them in the Finder, or by "ls" command.

Find hidden files in the Finder Window: Press Command-Shift-period

To find hidden files in terminal:

cd ~
ls -a ~
Enter fullscreen mode Exit fullscreen mode

Source lines to add

//source line added
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
Enter fullscreen mode Exit fullscreen mode

Reference:
1.https://blog.logrocket.com/how-switch-node-js-versions-nvm/
2.https://discussions.apple.com/thread/254493189?sortBy=rank

Top comments (0)