DEV Community

Bhavesh Kasturi
Bhavesh Kasturi

Posted on • Updated on

nvm command not found :(

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!

Top comments (21)

Collapse
 
gabrielduete profile image
Gabriel Duete

Thanks!! /o/

Collapse
 
isabelalima profile image
Isabela Lima

Thank you, this helped a lot!

Collapse
 
rinsama77 profile image
imrinzzzz

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

Glad It helped! :)

Collapse
 
viktor_k profile image
Viktor Kushniruk

I wish I had read your comment before following the article...

Collapse
 
samboosa5k profile image
samboosa5k

thank you! :D

Collapse
 
edwinb24 profile image
edwinb24

Thanks!

Collapse
 
moegts profile image
Mohammad Khalil

thanks!
πŸ˜πŸ‘Œ

Collapse
 
loftusjl profile image
Jesse Loftus

Perfect! Thank you! <3

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

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
 
santoshjava profile image
Santosh Sharma

Thank You..!

Collapse
 
herison profile image
Herison S.

Obrigadoooooooo

Collapse
 
ridhikgovind profile image
Ridhik Govind

This worked like a charm. Thanks a lot !

Collapse
 
saiafonua profile image
Saia Fonua

/usr/bin/curl: /usr/bin/curl: cannot execute binary file

I got this when trying to execute the curl command in the terminal

Collapse
 
bossfelfo profile image
fbf.dev

This was really helpful, though in my case - I had to nano ~/.bash_profile and added the code snippet