📅  最后修改于: 2023-12-03 14:43:55.187000             🧑  作者: Mango
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.
To install NVM on your Linux machine, follow these steps:
Before installing NVM, make sure the following dependencies are installed on your machine:
You can install them using your package manager. For example, on Ubuntu, run:
sudo apt-get install curl sudo git
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.
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.
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.
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.
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.