DEV Community

loading...

nvm command not found :(

Bhavesh Kasturi
Full Stack Developer - MERN
Updated on ・1 min read

Node Version Manager (NVM) is a tool used to manage multiple active Node.js versions.

If you're trying to install NVM(Node Version Manager) in WSL you probably may run into this error.

-bash: nvm: command not found
Enter fullscreen mode Exit fullscreen mode

What is WSL ?

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup.

How to fix this error ?

  • Installation

To install nvm use the following cURL or Wget command

bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Enter fullscreen mode Exit fullscreen mode
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Enter fullscreen mode Exit fullscreen mode
  • nvm command not found :(

Running either of the above commands downloads a script and runs it, but if you type nvm and if you get bash: nvm: command not found it happens because the source is missing from the following profile files

~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc
Enter fullscreen mode Exit fullscreen mode


To fix this simply follow these steps.

  • Steps

1) Type the following command.

nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

2) Add the source lines from the snippet below to the correct profile file at the bottom.

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Enter fullscreen mode Exit fullscreen mode

3) Close and restart the terminal it should fix the error!

The official documentation on GitHub is really helpful.

Thanks for reading!

Discussion (11)

Collapse
samboosa5k profile image
samboosa5k

thank you! :D

Collapse
isabelalima profile image
Isabela Lima

Thank you, this helped a lot!

Collapse
santoshjava profile image
Santosh Sharma

Thank You..!

Collapse
gsingh profile image
G.Singh

Thank you good Sir.

Collapse
edineu profile image
Neu • Edited

Hej,
How did you exactly add this snippet code to the profile?

Collapse
duhbhavesh profile image
Bhavesh Kasturi Author

Hi, it was using markdown you can check this GitHub article

Collapse
pszujewski profile image
Peter H. Szujewski

YOU ARE THE BEST! Thank you.

Collapse
rinsama77 profile image
rinzzzz

Than you!!! I downloaded oh-my-zsh and it replaced my previous .zshrc file. This helps a lot TT.

Collapse
duhbhavesh profile image
Bhavesh Kasturi Author

Glad It helped! :)

Collapse
kvng777 profile image
Kevin G.

Many thanks for sharing this solution!

Collapse
vinimartins profile image
Vinicius Martins

thaaanks bro!