How to install nvm in windows linux subsystem Ubuntu 22.04.2 TLS

Installing NVM (Node Version Manager) in Windows Subsystem for Linux (WSL) is a relatively simple process. Here are some steps:

Step 1: Update package list

First, make sure Ubuntu's package list is up to date.

sudo apt update

Step 2: Install dependencies

Then, install some necessary dependencies.

sudo apt install build-essential libssl-dev

Step 3: Download and install NVM

Next, download and install NVM from the GitHub repository. You can use curlor wgetto download the installation script.

Use curl:

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

Or use wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

NOTE: At the time of writing this article, the latest version of NVM is 0.38.0. It is recommended that you go to NVM's GitHub page to check the latest version.

Step 4: Configure environment variables

After the installation is complete, you need to add NVM to ~/.bashrcor ~/.zshrcin the configuration file of the shell you are using.

Normally, the installation script will do this step automatically. If not, you can manually add the following lines to your configuration file:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Then, execute the following command for the changes to take effect:

source ~/.bashrc

Or, for Zsh users:

source ~/.zshrc

Step 5: Test NVM

Finally, test whether NVM is installed successfully.

nvm --version

If all goes well, this will output the version number of NVM.

In this way, you have successfully installed NVM in Ubuntu 22.04.2 LTS with WSL. Now, you can use nvm installcommands to install different versions of Node.js. For example:

nvm install 16
nvm use 16

This will install and use the 16.x version of Node.js.

Supongo que te gusta

Origin blog.csdn.net/gaoxu529/article/details/132777973
Recomendado
Clasificación