📜  linux install nvm - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:43:55.187000             🧑  作者: Mango

Linux Install NVM - Shell-Bash

NVM (Node Version Manager) is a popular tool used to manage multiple active versions of Node.js on a single machine. This allows developers to switch between different versions of Node.js for different projects with ease.

Installation

To install NVM on your Linux machine, follow these steps:

Step 1: Install dependencies

Before installing NVM, make sure the following dependencies are installed on your machine:

  • curl
  • sudo
  • git

You can install them using your package manager. For example, on Ubuntu, run:

sudo apt-get install curl sudo git
Step 2: Install NVM

To install the latest version of NVM, run the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

This command downloads and runs the installation script for NVM.

Step 3: Activate NVM

After installing NVM, you need to activate it by running the following command:

source ~/.bashrc

This command adds the NVM environment variables to your shell. Alternatively, you can also close and reopen your shell.

Step 4: Install Node.js

Once NVM is activated, you can install any version of Node.js that you need. For example, to install the latest LTS version of Node.js, run the following command:

nvm install --lts

This command installs the latest LTS version of Node.js.

Step 5: Use Node.js

To use the version of Node.js that you just installed, run the following command:

nvm use --lts

This command sets the default Node.js version to the latest LTS version. You can now use Node.js as usual.

Conclusion

Installing NVM on Linux is a straightforward process that enables you to manage multiple versions of Node.js on your machine. This allows you to work with different versions of Node.js for different projects, and ensures that your projects are always running on the correct version of Node.js.