How to Use NVM Install: A Complete Guide to Node Version Manager
When I first started my journey into web development, I thought that installing Node.js was a one-time task. I went to the official website, clicked the big green button, and everything worked perfectly. However, three months later, I joined a freelance project that was built four years ago. Suddenly, my modern version of Node.js wouldn’t run the code. I spent an entire afternoon uninstalling and reinstalling different versions manually, pulling my hair out in frustration. That was the day I discovered NVM, or Node Version Manager. If you have ever felt that same frustration, or if you want to avoid it entirely, you are in the right place.
Node.js moves incredibly fast. New updates come out frequently, and while staying updated is usually good, many companies and projects rely on specific older versions for stability. This creates a conflict on your computer if you only have one version of Node installed. This is where the “nvm install” process becomes your best friend. NVM is a tool that allows you to have multiple versions of Node.js living on your computer at the same time without them fighting each other. You can switch from version 14 to version 20 in a matter of seconds.
Why You Should Use NVM Instead of the Standard Installer
Most beginners make the mistake of using the standard installer from the Node.js website. While that works for a single project, it is very inflexible. When you use a direct installer, Node is placed in a system-level folder. If you need to change it, you have to manually delete files, which often leaves behind “ghost” configurations that cause errors later. NVM handles all of this for you by creating a dedicated space for every version you download.
I personally recommend NVM because it also solves many permission issues. Have you ever tried to install a package and received a “EACCES” permission denied error? This often happens because the global Node folder is protected by the system. When you use NVM, it installs Node in your user directory, meaning you rarely have to use “sudo” again. This makes your development environment much safer and easier to manage. It is a professional standard that most senior developers expect you to know.
Preparing Your Machine for Installation
Before we dive into the installation steps, there is one very important rule: you should try to uninstall any existing versions of Node.js first. If you leave a manually installed version of Node on your system and then try to put NVM on top of it, they will often clash. Your computer won’t know which one to listen to, and you might find that your “nvm use” commands don’t actually change anything.
On Windows, go to your Control Panel and uninstall Node.js. On a Mac or Linux machine, it can be a bit more complicated, involving the removal of files in /usr/local/bin, but usually, a simple uninstall is enough to get started. Once your system is clean, you are ready to set up the foundation for a much better workflow.
How to Install NVM on Windows
Windows users have a slightly different path than Mac or Linux users. You will be using a project called “nvm-windows” created by Corey Butler. It is a fantastic tool that mimics the original NVM functionality specifically for the Windows environment.
First, you need to go to the GitHub releases page for nvm-windows. Look for the “nvm-setup.exe” file. Download it and run it just like any other program. During the installation, it will ask you where you want to install NVM and where you want the Node.js symlink to be. I suggest keeping the default locations unless you have a very specific reason to change them. Once the installer finishes, you need to open a new terminal. This is a common point of confusion: if you have a command prompt window open during the installation, it won’t recognize the new command. Close it and open a fresh one.
Type nvm version into your command prompt. If you see a version number, congratulations, you have successfully installed the manager. Now, the real fun begins. To get your first version of Node, you will type nvm install latest for the absolute newest features, or nvm install lts for the version that is most stable for long-term work. I always suggest starting with the LTS version because it is what most employers and tutorials use.
Installing NVM on macOS and Linux
For those of you on a Mac or a Linux distribution like Ubuntu, the process involves the terminal and a simple script. You don’t download an .exe file here. Instead, you use a “curl” or “wget” command to pull the installation script directly from the official NVM repository.
Open your terminal and paste the install script provided in the NVM documentation. It usually looks something like curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash. After you run this, it might look like nothing happened, but the script has actually downloaded NVM and added some lines to your profile file (like .bashrc or .zshrc).
Here is where many beginners get stuck: they try to type nvm immediately and get a “command not found” error. This is because the terminal needs to be told to “refresh” its settings. You can either close and reopen the terminal, or you can run the command source ~/.zshrc (if you are on a modern Mac) or source ~/.bashrc (if you are on Linux). This tells the terminal to read the new instructions and recognize the NVM command.
The Power of the “nvm install” Command
Once NVM is set up, the command nvm install becomes your primary tool. But it is more versatile than people realize. You don’t just have to install the newest version. Let’s say you are following a tutorial from 2021 that uses Node version 16.14.0. You can simply type nvm install 16.14.0 and NVM will go out, find that exact version, and download it for you.
One thing I love about this is that it also installs the corresponding version of NPM (Node Package Manager) automatically. Every version of Node is bundled with a specific version of NPM that is guaranteed to work with it. By using NVM, you ensure that you never have a mismatch between your Node version and your package manager, which is a very common cause of bugs in modern web development.
If you are working in a professional environment, you should get used to the command nvm install --lts. LTS stands for Long Term Support. These versions are maintained for years and are the safest bet for production applications. In my years of coding, I have found that using the “latest” version is fun for playing with new features, but the LTS version is where the real work happens.
Managing Multiple Versions and Switching
Installing versions is only half the battle. You also need to know how to switch between them. This is done with the nvm use command. For example, if you have version 18 and version 20 installed, and you want to work on a project that needs version 18, you just type nvm use 18.
A helpful tip that I use every day is the nvm ls command. This lists all the versions currently sitting on your computer. It will even show you which one you are currently using with a little arrow or a color change. If you want to see every version of Node that has ever been released (and there are hundreds), you can type nvm ls-remote. This is great if you need to find a very specific old version for a legacy project.
I remember a project where the client had an app that only ran on Node version 10. This version is ancient by tech standards. Without NVM, I would have had to break my entire local setup to help them. With NVM, I simply typed nvm install 10, did the work, and then typed nvm use 20 to go back to my modern projects. It turned a potential nightmare into a five-second task.
The Magic of .nvmrc Files
If you want to look like a pro to your teammates, you should start using .nvmrc files. Imagine you have five different projects. Instead of trying to remember which Node version each one uses, you can create a tiny file in the project folder named .nvmrc. Inside that file, you just write the version number (e.g., 18.17.0).
When you navigate to that folder in your terminal, you can simply type nvm use without any numbers. NVM will look at the file, see that it says 18.17.0, and switch to that version automatically. Some developers even set up their terminals to switch versions automatically the moment they enter a folder. This level of automation prevents mistakes and ensures that everyone on a team is using the exact same environment.
Troubleshooting Common “nvm install” Issues
Even with a great tool like NVM, things can go wrong. The most common issue is the “Command Not Found” error. This almost always means that the PATH variables were not set up correctly. On Windows, this might require a restart of your computer. On Mac or Linux, it usually means the installation script couldn’t find your profile file. If you use a special shell like Oh My Zsh, you might need to manually add the NVM lines to your .zshrc file.
Another issue is permission errors on Linux. Sometimes users try to run sudo nvm install. You should actually avoid using sudo with NVM. NVM is designed to run per-user. If you use sudo, you might end up with files owned by the “root” user, which creates a huge mess later. If you get a permission error, it usually means the folder permissions in your home directory need to be fixed, not that you need more power.
Finally, keep an eye on your disk space. Each version of Node you install takes up a bit of room. If you have been using NVM for years, you might have 20 different versions of Node sitting there. You can use nvm uninstall <version> to clean up the ones you no longer need. I usually do a “spring cleaning” once every few months to keep my system lean.
Conclusion
Learning how to properly execute an “nvm install” and manage your environment is a rite of passage for web developers. It moves you from being someone who just “writes code” to someone who understands their “development environment.” By using NVM, you gain the flexibility to work on any project, regardless of how old or new it is, without the stress of breaking your system.
Whether you are on Windows, Mac, or Linux, the steps are straightforward: clean up your old Node installations, run the NVM installer, and then use the simple commands to download the versions you need. It is a small investment of time that pays off every single day of your career. Don’t be afraid to experiment with different versions, and always remember to check your LTS versions for the best balance of features and stability.
FAQ Section
Q: Can I use NVM if I already have Node.js installed?
A: Yes, but it is highly recommended to uninstall your current Node.js first. This prevents conflicts where your computer doesn’t know whether to use the NVM version or the system-installed version.
Q: Does NVM work on Windows PowerShell?
A: Yes! The nvm-windows version works perfectly with PowerShell, Command Prompt, and even Git Bash. Just remember to run your terminal as an Administrator during the initial setup if you encounter issues.
Q: How do I set a default Node version?
A: You can set a default version by typing nvm alias default <version>. This ensures that every time you open a new terminal, that specific version is ready to go.
Q: Is NVM the same as NPM?
A: No. NVM (Node Version Manager) manages the versions of Node.js itself. NPM (Node Package Manager) comes bundled with Node and manages the libraries/packages you use in your code.
Q: Are there alternatives to NVM?
A: Yes, there are other tools like “n” or “fnm” (Fast Node Manager). While “fnm” is becoming popular because it is written in Rust and is very fast, NVM remains the most widely used and documented tool in the industry.
