NVM and Node Preset

nvm and nodejs preset

NVM

Official website: Nvm Link

Installation

It’s recommended to use a VPN. To install or update nvm, you need to run the installation script. Use either of the following cURL or Wget commands:

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

or

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

Usage

After installation, restart your terminal, then you can use nvm.

nvm --version

Common Commands

nvm ls-remote # List all available node versions
nvm install v16.8.0 # Install specific node version
nvm use v16.8.0 # Use specific node version
nvm alias default v16.8.0 # Set default node version
nvm alias default node # Set current node version as default
nvm ls # List installed node versions
nvm uninstall v16.8.0 # Uninstall specific node version

NPM Registry Configuration

Check Current Registry

npm config get registry

Configure Taobao Registry

npm config set registry https://registry.npmmirror.com

Configure Official Registry

npm config set registry https://registry.npmjs.org