Location>code7788 >text

Install nvm and install nodejs via nvm

Popularity:643 ℃/2024-08-27 16:00:43

Reprinted with attribution:

1. Install nvm

Open a terminal and run the following command to download and install nvm:

curl -o- /nvm-sh/nvm/v0.39.1/ | bash

                           

Or use wget:

wget -qO- /nvm-sh/nvm/v0.39.1/ | bash

Once the installation is complete, close the terminal and reopen it to allow nvm to initialize.

2. View nvm installation results

You can check the installed version by using nvm -v, or by using the

nvm -v

             

3. Installing 13.14.0

Use nvm to install the specified version:

source ~/.bashrc

nvm install 13.14.0

nvm install 13.14.0 --npm-version 6.14.4

This will download and install version 13.14.0.

When completing the first step of the second operation, you need to exit the terminal to reconnect so that nvm can complete the initialization, if you do not exit, you can use source ~/.bashrc to complete the initialization.

 4.Switch to 13.14.0

To switch to the version you just installed, use the following command:

nvm use 13.14.0

This will change the current active version to 13.14.0.

5.Verify Installation

Verify that the version is installed correctly:

node -v

The output should showv13.14.0, confirming that it has been successfully installed.