You are currently viewing Getting Started with Node.js and NVM (Node Version Manager)

Getting Started with Node.js and NVM (Node Version Manager)

  • Post author:
  • Post category:Nodejs
  • Post comments:0 Comments
  • Post last modified:May 3, 2024

Node.js is a powerful runtime environment for building server-side applications using JavaScript. It allows developers to use JavaScript for both frontend and backend development. However, managing different Node.js versions across projects can be cumbersome. That’s where NVM (Node Version Manager) comes in handy. NVM allows you to easily switch between different versions of Node.js on your machine.

In this tutorial, we’ll walk through the installation and basic usage of NVM, along with examples.


  • Basic understanding of the command line interface (CLI).

Step 1: Installing NVM
First, we need to install NVM. Follow these steps:

  1. Open your terminal (command prompt for Windows users).
  2. Run the following command to download and install NVM:
curl -o- | bash
  1. Close and reopen your terminal window to ensure NVM is in your system’s PATH.

Step 2: Installing Node.js using NVM
Once NVM is installed, you can easily install different versions of Node.js. Here’s how:

  1. To list all available Node.js versions, run:
nvm ls-remote
  1. Choose a version to install and run the following command to install it. For example, to install Node.js version 14.17.0, run:
nvm install 14.17.0
  1. Once the installation is complete, you can verify the installed Node.js version by running:
node -v

Step 3: Switching Between Node.js Versions
NVM allows you to switch between different Node.js versions with ease. Here’s how:

  1. To list all installed Node.js versions, run:
nvm ls
  1. To use a specific Node.js version, run:
nvm use <version>

For example, to switch to Node.js version 14.17.0, run:

nvm use 14.17.0
  1. You can now verify the active Node.js version by running:
node -v

Step 4: Setting a Default Node.js Version
You can set a default Node.js version to be used across all terminals. Here’s how:

  1. To set a default Node.js version, run:
nvm alias default <version>

For example, to set Node.js version 14.17.0 as the default, run:

nvm alias default 14.17.0
  1. Now, whenever you open a new terminal window, the default Node.js version will be used.

In this tutorial, we’ve learned how to install and use NVM (Node Version Manager) to manage multiple Node.js versions on your machine. NVM makes it easy to switch between different Node.js versions for different projects, ensuring compatibility and flexibility in your development workflow.

With NVM, you can experiment with different Node.js versions, test your applications across different environments, and ensure seamless compatibility with dependencies.

Leave a Reply