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

WBOY
Release: 2024-02-21 12:54:30
forward
713 people have browsed it

如何在 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
    Copy after login
  2. Download and install Nvm. Run the following command in the terminal to clone the Nvm repository:

    git clone ~/.nvm
    Copy after login
  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
    Copy after login
  4. You can now use Nvm to install Node.js. Run the following command to list available Node.js versions:

    nvm ls-remote
    Copy after login
  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
    Copy after login
  6. After the installation is complete, you can use the following command to confirm whether Node.js is successfully installed:

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

    npm -v
    Copy after login

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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!