Facebooktwitterredditpinterestlinkedintumblr

If you’ve ever encountered the “nvm command not found” error, you know it can be frustrating. Fortunately, you can do a few things to fix the issue and get your Node Version Manager installation up and running again.

This article will walk you through the steps for fixing the nvm command not found error on Linux, Windows, and Mac.

What is NVM?

nvm (Node Version Manager) is a program for downloading and installing Node.js. With nvm, you can easily switch between multiple versions of Node.js from the command line without entering any configuration files or directories.

What is Node.js?

The Node.js platform is an open-source, cross-platform back-end JavaScript runtime that utilizes the V8 engine and executes JavaScript code outside a web browser.

Developers can use Node.js to write command-line tools in JavaScript and server-side scripting—writing scripts on the server to generate dynamic web page content before it’s sent to the client’s web browser.

How to Check if nvm is Installed?

To solve the issue with the “nvm command not found” error, check if your system can find the nvm command.

Run this command:

$ nvm --version
bash: nvm: command not found

If you see the error “nvm: command not found,” it means nvm isn’t installed on your system. If it was installed, it’s now corrupted, and you should follow these steps to fix the issue.

How to Reinstall nvm?

If you cannot run nvm, you can reinstall it by following these steps, depending on your operating system.

On Linux

If you’re using Linux, fixing the “nvm command not found” error is restarting your computer and then uninstalling and reinstalling nvm using your system’s package manager.

To uninstall and reinstall nvm on Linux:

  • Open a Terminal window and download nvm by running this command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  • Close your Terminal window and reopen a new Terminal window.
  • Check if nvm is working now by running:

This should fix the issue and allow you to use Node.js on your Linux system again.

If it doesn’t work, you can reload the configuration by running this command:

source ~/.bashrc

If you’re using the ZSH shell, edit your shell configuration file by typing:

nano ~/.zshrc

Add the following to the bottom of your configuration file:

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"

Close and restart the terminal for the changes to take effect.

On macOS

If you’re getting the “nvm command not found” error on a Mac, you’ll first want to restart your computer and try again. If that doesn’t work, try uninstalling and reinstalling nvm using Homebrew.

To uninstall nvm:

brew uninstall nvm

To install nvm:

brew update
brew install nvm

If you’re using the ZSH shell, edit your shell configuration file by typing:

nano ~/.zshrc

Add the following to the bottom of your configuration file:

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
  • Close your Terminal window and reopen a new Terminal window.
  • Check if nvm is working now by running:
% nvm --version
0.39.1

This should fix the issue and allow you to use Node.js on your Linux system again.

This should resolve the issue and allow you to use Node.js again on your Mac.

On Windows

If you’re getting the “nvm command not found” error on Windows, you can reinstall nvm.

  • Follow the setup installer.
  • Once the setup installer has been completed, open a Command Prompt.
  • Verify nvm has been installed successfully by running:

You should now be able to use nvm on your Windows computer without issues.

Conclusion

If you’re seeing the “nvm command not found” error, there are a few things you can do to fix the issue. First, try restarting your computer, then uninstalling and reinstalling nvm.

If that doesn’t work, try adding an entry for nvm to your PATH environment variable. With any luck, one of these solutions will get you up and running with Node.js again.

Tim Miller

Tim has always been obsessed with computers his whole life. After working for 25 years in the computer and electronics field, he now enjoys writing about computers to help others. Most of his time is spent in front of his computer or other technology to continue to learn more. He likes to try new things and keep up with the latest industry trends so he can share them with others.

Leave a Comment