Home  >  Article  >  Computer Tutorials  >  How to install Node and Npm via Nvm on GNU Linux?

How to install Node and Npm via Nvm on GNU Linux?

WBOY
WBOYforward
2024-02-21 12:54:30715browse

如何在 GNU Linux 上通过 Nvm 安装 Node 和 Npm?

On GNU/Linux systems, you can use Nvm (Node Version Manager) to manage the installation of Node.js and Npm. Nvm is a handy tool that allows you to easily manage and switch between different versions of Node.js. Nvm allows you to install and use multiple Node.js versions simultaneously on the same computer, allowing for more flexibility in development and testing. In this way, you can quickly switch Node.js versions according to the requirements of the project without worrying about version conflicts. Through Nvm, you can manage your Node.js environment more efficiently and ensure the stability and reliability of the project.

Follow these steps to install Node.js and Npm using Nvm on GNU Linux:

  1. Open a terminal and make sure Git is installed on your system. If Git is not installed, you can install it using the following command:

    sudo apt update
    sudo apt install git
  2. Download and install Nvm. Run the following command in the terminal to clone the Nvm repository:

    git clone ~/.nvm
  3. Add the following code in the terminal's configuration file (such as bashrc, zshrc, etc.) to load Nvm every time the terminal is started:

    echo "source ~/.nvm/nvm.sh" >> ~/.bashrcsource ~/.bashrc
  4. You can now use Nvm to install Node.js. Run the following command to list available Node.js versions:

    nvm ls-remote
  5. Select the version of Node.js you want to install and run the following command to install it. For example, to install Node.js 14.x version, you can run:

    nvm install 14
  6. After the installation is complete, you can use the following command to confirm whether Node.js is successfully installed:

    node -v
  7. Npm will be installed with Node.js. You can use the following command to verify that Npm is installed correctly:

    npm -v

Now, you have successfully installed Node.js and Npm via Nvm on GNU Linux. You can use Nvm to manage and switch between different versions of Node.js to meet your project needs.

The above is the detailed content of How to install Node and Npm via Nvm on GNU Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete