NVM is the Node version manager, a simple bash script that manages multiple active Node.js versions, allowing us to set the default Node version and switch between different versions in different development environments.
Install the NVM
- Open the download address and download the installation package.
- Double-click the installation file nVM-setup.exe, agree to the protocol and click Next
- Select the NVM installation path
- Select the nodeJS path
- Click the Install button to install
- After installation open the console and enter
nvm
If the installation is successful, the following information is displayed:
The NVM takes too long to install Node and NPM
The default node image source of the NVM is https://nodejs.org/dist. Downloading from the default image source is slow. Therefore, you can change the image source to speed up the downloading
- Locate the folder where you installed NVM and open it
settings.txt
file
- Two lines of configuration are added and replaced
node
andnpm
Download source for Taobao mirror source
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Copy the code
Install Node.js using NVM
- The input terminal
nvm ls
View the installednode.js
Version.*
Selected is the version currently in use.
nvm ls
Copy the code
- use
nvm
Install the specified versionnode.js
NVM install 14.17.6Copy the code
As shown in the following figure, the installation of the specified version of Node.js and NPM is successful
Added a folder for the specified version to the NVM folder directory
The folder contains installed packages for Node, NPM, and NPX
- Use the specified version
node.js
To see thenode
andnpm
Version.
NVM use 14.17.6Copy the code
- Uninstall the specified version
node.js
NVM uninstall 14.17.6Copy the code
Command Prompt description
nvm arch [32|64]
: Shows whether node runs on 32-bit or 64-bit.nvm current
: Displays the active version.nvm install <version> [arch]
: Installs Node. Version can be a specific version or latest stable version. The optional arch parameter specifies whether to install the 32-bit or 64-bit version, which defaults to system bits. You can add –insecure to bypass SSL for the remote server.nvm list [available]
: Displays the installed list. The optional parameter available displays all versions that can be installed. List can be simplified to ls.nvm on
: Enables node.js version management.nvm off
: Disables node.js version management.nvm proxy [url]
: Sets the download agent. Displays the current proxy without the optional URL. Setting the URL to None removes the proxy.nvm uninstall <version>
: Uninstalls the specified version of Node.nvm use [version] [arch]
: Use the specified version of Node. 32/64 bits can be specified.nvm root [path]
: Sets the directory to store different versions of Node. If no, the current directory is used by default.nvm version
: Displays the NVM version. Version can be simplified to v.nvm node_mirror [node_mirror_url]
: Sets the node mirroring. The default ishttps://nodejs.org/dist/
. If the URL is not written, the default URL is used. You can view the Settings in installation directory settings. TXT or perform operations in this file.nvm npm_mirror [npm_mirror_url]
: Sets the NPM mirror. The default ishttps://github.com/npm/cli/archive/
. If the URL is not written, the default URL is used. You can view the Settings in installation directory settings. TXT or perform operations in this file.
Installation of yarn
- Use what’s already installed
npm
To install theyarn
npm install yarn -g
Copy the code
- To view
yarn
version
yarn -v
Copy the code
- use
nvm
forThe node version
Manage after eachThe node version
All the following need to be installedyarn
After the installation, the specified version folder will be addedyarn
file
Set the Taobao mirroring for NPM and YARN
Taobao NPM image is a complete nPMjs.org image, you can use this instead of the official version (read only) to greatly improve the download speed of the package, the synchronization frequency is currently 10 minutes to ensure as much as possible with the official service synchronization.
- Set up the
npm
Taobao mirror
npm config set registry http://registry.npm.taobao.org/
Copy the code
- Set up the
yarn
Taobao mirror
yarn config set registry http://registry.npm.taobao.org/
Copy the code
- Example Query the current mirror
npm get registry
yarn config get registry
Copy the code