How to fix "command not found: nvm" in Node
Table of Contents
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:
BASHnvm --version
Sometimes, when you run this command, you might get:
BASHcommand not found: nvm
In this post, we'll learn how to fix this error in Node.
How to fix command not found: nvm
As mentioned before, to double-check that you have NVM installed, you can run the following command:
BASHnvm --version
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:
BASHexport NVM_DIR="$HOME/.nvm"
This will set the NVM_DIR variable to the location of your NVM installation.
Now, let's load NVM:
BASH[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Finally, let's load NVM bash_completion:
BASH[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
If done properly, you should be able to run the following command:
BASHnvm --version
And get back a version number.
How to open your bash file in Visual Studio Code
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:
BASHcode ~/.bashrc
If you are using ZSH, you can run the following command:
BASHcode ~/.zshrc
Conclusion
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!
- Getting Started with TypeScript
- Managing PHP Dependencies with Composer
- Create an RSS Reader in Node
- Getting Started with Electron
- Git Tutorial: Learn how to use Version Control
- How to deploy a Node app using Docker
- Using Puppeteer and Jest for End-to-End Testing
- Build a Real-Time Chat App with Node, Express, and Socket.io
- Creating a Twitter bot with Node.js
- Using Push.js to Display Web Browser Notifications
- Setting Up Stylus CSS Preprocessor
- How To Create a Modal Popup Box with CSS and JavaScript