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
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
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- 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
To fix this simply follow these steps.
- Steps
1) Type the following command.
nano ~/.zshrc
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
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)
Thanks!! /o/
Thank you, this helped a lot!
Than you!!! I downloaded oh-my-zsh and it replaced my previous .zshrc file. This helps a lot TT.
Glad It helped! :)
I wish I had read your comment before following the article...
thank you! :D
Thanks!
thanks!
😍👌
Perfect! Thank you! <3
Thank you good Sir.
Hej,
How did you exactly add this snippet code to the profile?
Hi, it was using markdown you can check this GitHub article
YOU ARE THE BEST! Thank you.
Thank You..!
Obrigadoooooooo
This worked like a charm. Thanks a lot !
/usr/bin/curl: /usr/bin/curl: cannot execute binary file
I got this when trying to execute the curl command in the terminal
This was really helpful, though in my case - I had to nano ~/.bash_profile and added the code snippet