Node Version Manager (NVM

Node Version Manager (NVM): Manage Multiple Versions of Node.js on a Single System

Node.js is a JavaScript runtime that allows you to run JavaScript code on the server side, and it’s commonly used for building web applications and server-side scripting. 

Node Version Manager (NVM) is a tool that allows you to manage multiple versions of Node.js on your computer.

Node Version Manager makes it easy to switch between different versions of Node.js so that you can work on various projects with the appropriate Node.js version without conflicts.

NVM is available for various Unix-like systems (such as Linux and macOS) and Windows. 

NVM allows you to set both a global and local Node.js version. The global version is the default for your system, while the local version can be set on a per-project basis, ensuring that each project can use the appropriate Node.js version.

NVM also provides commands to update itself and uninstall Node.js versions when they are no longer needed.

You can use the following steps to install Node Version Manager (NVM) on your PC

  1. Install NVM via curl or wget
    Open your terminal. For the installation, you will use the command line.
    Now you can install NVM using the curl command or wget commands depending on the command available on your device.
    For curl, use the command:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
    The NVM installation script will be downloaded and executed with this command. Replace 0.39.0 with the recent version.
    You can also use wget.
    For Wget, use the following command :
     wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  2. Close and Reopen your terminal
    To check that NVM is available in your current terminal session, either close and reopen your terminal or perform the following command to refresh your terminal :
     source ~/.bashrc
    If you’re using ~/.zshrc (Zsh), replace ~/.bashrc with ~/.zshrc.
  3. Verify NVM installation 
    To verify NVM is installed correctly, run the following command :
     nvm –version
    This should display the version of NVM that you installed.
  4. Install specific node versions
    The specific version of Node.js can be installed by running the following command:
     nvm install <version>
    Replace <version> with the version of Node.js required for the project. 
    (example: nvm install v14.19.3)
  5. Set Default Node.js Version
    If you want to set a default Node.js version to use, you can run:
    nvm alias default <version>
    Replace <version>with the Node.js version you want as the default.
    Example: nvm alias default 16.15
  6. Switch Between Node.js Versions
    You can easily switch between installed Node.js versions using the nvm use command. 
    For example, nvm use 16.16.0
  7. List all installed Node js versions
    To list the Node.js versions currently installed on your system using Node Version Manager (NVM) use the command nvm ls. When you run this command, NVM will display a list of installed Node.js versions along with an indication of which version is currently in use (marked with an arrow ->).
  8. List all available versions of Node js
    Use the command nvm ls-remote to list the remote or available versions of Node.js that you can install using Node Version Manager (NVM). It displays a list of Node.js versions that can be installed using NVM.
  9. Uninstall a specific version of Node.js
    The nvm uninstall command in Node Version Manager (NVM) is used to uninstall a specific version of Node.js from your system. This can be useful if you want to remove a Node.js version that you no longer need or if you need to free up disk space.
    Example: nvm uninstall 14.15.4

Conclusion

Node Version Manager (NVM) is a valuable tool for developers who work with Node.js. It simplifies the management of multiple Node.js versions on a single machine, allowing developers to switch between versions easily, isolate projects with different version requirements, and maintain global npm packages specific to each Node.js version. NVM is a powerful utility that streamlines the development process and ensures compatibility and consistency across different projects. It’s a must-have for Node.js developers who need to work with different Node.js versions in their daily workflow.

Sreyas is a prominent software and mobile app development firm, boasting extensive expertise in UI/UX design. Our global presence allows us to offer a comprehensive range of services, including data migration, database management, web hosting, infrastructure management, and more to clients worldwide.

Recent Blogs


Posted

in

by

Tags:

To Know Us Better

Browse through our work.

Explore The Technology Used

Learn about the cutting-edge technology and techniques we use to create innovative software solutions.