When you install Node, it comes bundled with NVM, which is the Node Version Manager. It allows you to install multiple versions of Node and switch between them.
To check if you have NVM installed, run the following command:
Sometimes, when you run this command, you might get:
command not found: nvm
In this post, we'll learn how to fix this error in Node.
As mentioned before, to double-check that you have NVM installed, you can run the following command:
If it goes well, you should get back a version number, but if not, you might get
command not found: nvm.
The reason for this is that NVM is not in your PATH.
To fix this, open up your
/.bashrc file and add the following line:
This will set the NVM_DIR variable to the location of your NVM installation.
Now, let's load NVM:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Finally, let's load NVM bash_completion:
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
If done properly, you should be able to run the following command:
And get back a version number.
A recommended way to open your bash file is to use the
code command. This command will open the file in Visual Studio Code.
All you need to do is pass it the path to your file.
To open your bash file, run the following command:
If you are using ZSH, you can run the following command:
In this post, we learned how to fix the
command not found: nvm error in Node.
Simply add the aforementioned lines to your bash file and you should be good to go after you restart your terminal.
Thanks for reading!
Leave us a message!