HomeInstallation

ZSH command not found nvm error in Mac reason and solution

Like Tweet Pin it Share Share Email

In this artcile I will explain you the reason and solution for “zsh: command not found: nvm” error.

I installed nvm package manager successfully. Later I closed the terminal. Again when I reopened the terminal and typed “nvm ls-remote” command, I received below this error – “zsh: command not found: nvm”.

After reading lot of artciles and forums ultimately I resolved it. Further in this article I will explain you the solution and reason for this issue.

Before reading this article please make sure you have installed nvm in Mac.

You can read our artcile details article Install Java, Node JS, Angular, Maven, NVM, IntelliJ IDEA, Visual Studio on Mac.

Please read this complete article and follow the steps.

Solution for zsh: command not found: nvm

Basically, we need to edit .bash_profile, .zshrc, or .profile files and add the below given lines.

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

For me I added these 2 lines in .bash_profile and .zshrc file. It worked for me.

In case after adding the above 2 lines you are getting same error. Then you need to add these 2 lines in .profile file also.

Please find few tips to add these lines :

  • In order to add above lines, you need to open terminal.
  • You can use vim command to edit the files.
  • To make files editable press press “i”.
  • Use :wq! to save the changes in the files.

Above mentioed are few useful points helps you to edit and save the records using Mac terminal.

Use below command to edit .bash_profile file.

vim ~/.bash_profile 

In order to edit .zshrc file, you can type this command.

vim ~/.zshrc

Please use this command to edit .profile file.

vim ~/.profile

Once these all done, you can run these commands to reload .bash_profile, .zshrc, or .profile files.

source  ~/.bash_profile
source  ~/.zshrc
source  ~/.profile

Further, let us test your changes.

Testing NVM directory and installation

Once you have done the above changes. Now its time to test whether the problem is solved or not.

In order to test it, please follow the below mentioned commands.

  • Open the terminal in your Mac book.
  • Now type “echo NVM_DIR” and press return key. You should receive NVM_DIR as output.
[email protected] ~ % echo NVM_DIR 
NVM_DIR
[email protected]Vipins-MacBook-Pro ~ % 
  • Type this command in terminal to check nvm installation “nvm ls-remote”. Once you enter this command you will receive many versions of nvm. I have mentioned the very limited version here as output.
[email protected] ~ % nvm ls-remote
        v0.1.14
        v0.1.15
        v0.1.16
        v16.6.0
->      v16.6.1
        v16.6.2
[email protected] ~ %              

Conclusion

Finally, you learnt how to resolve “zsh: command not found: nvm” error.

Thanks for reading this article. Please share your comments. Our team will help you to solve your doubts.

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *