While using Node.js and NVM, I encountered the error “nvm command not found.” It is very frustrating, but I found a way to fix this error and thought I would share it with you.
You have probably faced this issue too. It can be overwhelming, but there is an easy solution.
I went through the same problem and found the best methods to resolve it. So, if you want to get out of this frustrating situation, I will show you how to fix the “nvm command not found” error.
What is NVM?
NVM stands for “Node Version Manager.” It is a tool to manage multiple versions of Node.js on the same machine and switch between them easily.
This can be useful if you are running multiple projects with different Node.js versions or need to switch between versions quickly.
What is Node.js?
Node.js also makes it easy to share code between the server and client side and data storage solutions like MongoDB or Couchbase.
Checking if NVM is Installed
The first step is to check if your system has NVM. You can do this by running the command “nvm –version” on the terminal. If the command runs without an error, NVM is installed and working properly.
But if you come across the dreaded “NVM command not found” error, then this means that NVM is not on your computer. Or, perhaps it is not configured correctly.
What are the Sources of the “Nvm Command Not Found” Error?
There can be several reasons why the “nvm command not found” error appears. Below are some of the common reasons:
- You haven’t installed the nvm.
- You are missing the NVM configuration file.
- You do not have the NVM environment variable set up correctly.
- The nvm command is not in your system PATH.
Simple Methods to Fix “Nvm Command not Found”
Reinstalling NVM is very simple. All you need to do is to run the command. However, the process differs on different operating systems such as macOS, Linux, and Windows.
If you get the error “nvm command not found” on macOS, it is time to uninstall and reinstall the nvm. But how do you do it on macOS? We use Homebrew. Sound hard with this terminology! Don’t worry. These commands will set you up.
To Uninstall NVM:
- Open the terminal and type in
brew uninstall nvm
To Install NVM:
- For installations, start with the command
brew install nvm
- Close the terminal and click on command+T to open the terminal again.
- Now let’s check if the installation and configuration have been set properly by running.
% nvm –version
By now, you should be able to see the version of nvm. If you can, then the nvm is installed and configured properly.
This will allow you to run Node.js and related without any errors.
Now it become interesting for Windows users. The error “nvm command not found” is simple to solve. Below are the straightforward instructions.
1. Open your browser. Type windows-nvm repository and download the nvm-setup.exe.
2. Run the nvm-setup.exe and follow the instructions to install it.
3. Once you’re complete, open the command prompt and type “nvm --version”
If you can see the version of NVM, it means you have successfully installed and configured NVM.
On Linux User
The process is different for Linux users. You need first to restart your computer. Then do the uninstallation and reinstallation of the nvm while using the system’s package manager.
- Open the terminal. Run the below command to download the nvm
- After the installation, close the terminal and open it again.
- Check if you are able to see the version of nvm by running the command
- If you can see the version, then you will need to reload the configurations by running
- Now, check the version of nvm again, and you should be able to see it.
Related: How to Fix Mac Windowserver High CPU
NVM is a powerful tool for developers who need to manage multiple Node.js versions on the same machine and switch between them easily.
With NVM, you can easily keep your development environment up to date while quickly switching between different versions.
Its installation is not hard, but it does vary from one operating system to another. Try out NVM and experience the power of Node.js!