Basic use of NVM (nvm-windows)

What is NVM

nvm (node.js version management) is a nodejs version management tool.
?

Note: The official nvm does not support windows, so windows need to install nvm-windows (hereinafter referred to as nvm)

nvm-window download address: Releases · coreybutler/nvm-windows · GitHub

The 8 downloaded files refer to:

nvm-noinstall.zip: Green installation-free version, but configuration is required before use

nvm-noinstall.zip.checksum.txt: green installation-free version checksum

nvm-setup: installation package, click to install after downloading

nvm-setup.zip: Installer compressed package

nvm-setup.zip.checksum.txt: Installation package checksum.

nvm-update.zip: nvm update package

nvm-update.zip.checksum.txt: Update checksum

Source code(zip): source code in zip compression format

Sourc code (tar.gz): source code in tar.gz compressed format, generally used in Linux systems

v1.1.11 Baidu Netdisk download address: https://pan.baidu.com/s/1l9C_nbhhAxSDiknFRd_RvA?pwd=5gks

v1.1.12 Baidu Netdisk download address: https://pan.baidu.com/s/19wJILr2SrtDUTusgDENcNQ?pwd=j3kd

Note: Try to install the latest version, otherwise the latest version of node will not be downloadable.

Install nvm

Note: If you have installed node.js, you need to completely uninstall the installed node, including the configured environment variables

If nodejs has been installed, you can uninstall it or install nvm directly. During the installation process, you will be prompted whether to use nvm to control the installed nodejs:

(1) Selecting Yes will move the installed node.js to the nodejs installation directory specified during the installation process (environment variables will not be cleared, it is recommended to clear them, but it will not affect the use of nvm)

(2) Select No, the installed nodejs will not be version controlled. You can use the command nvm off to disable it once, and then use the command nvm on to open it.

1. Double-click the downloaded exe

2. Agree to the agreement

3. Select the installation path of nvm (default is C drive, it is recommended to change it to other drives)

4. Select the nodejs path for subsequent installation (default is C drive, it is recommended to modify it to other drives)

5. Confirm installation

6. Open cmd and enter the command nvm / nvm -v to confirm whether the installation is successful.

Notice:

1. If the nodejs installation path is not selected during installation, it can also be modified in the nvm/settings.txt file.

root: D:\Program\RuntimeEnvironment\\
vm // nvm installation path
path: D:\Program\RuntimeEnvironment\\
ode // nodejs installation path

2. If you modify the nodejs installation path, but there is no set folder in the specified path, don’t worry, just install any nodejs version.

nvm basic instructions

nvm list available // Display all node.js versions that can be installed
nvm install <version> //Install node.js version is the version number
nvm install stable // Install the latest stable version
nvm uninstall <version> // Uninstall the specified version of nodejs
nvm ls // Display all installed node.js versions
nvm use <version> // Switch to use the specified nodejs version
nvm off // Disable node.js version management (do not uninstall anything)
nvm on // Enable node.js version management (enabled by default)

Install nodejs

1. Open Windows PowerShell and enter the command nvm list available to view the installable version.

2. Enter the command nvm install (if the node installation path is not modified, it will be installed on the C drive by default)

3. node -v to check whether node is installed successfully

Configure npm global installation location

After nodejs is successfully installed, it comes with npm, and no additional installation is required. However, regardless of whether the nodejs installation path is modified or not, packages installed globally through npm i -g xx will be installed on the C drive by default. To modify, just enter the following two lines of commands in Windows PowerShell:

/*
* The path can be specified by yourself. It is recommended that the path where nodejs is installed is at the same level as the node_modules folder.
*/
npm config set prefix "D:\Program\RuntimeEnvironment\\
ode\\
ode_global"
npm config set cache "D:\Program\RuntimeEnvironment\\
ode\\
ode_cache"

After executing the above command, the node_global and node_cache folders will not be created. They will be automatically created after executing npm i -g xx.

Configuring environment variables

Note: If you have not modified the npm global installation path, you do not need to configure environment variables.

1. Create the variable NPM_HOME whose value is the path specified through the command line command

2. Fill in the newly added NPM_HOME in the variable Path (you can also directly fill in the path specified through the command line command)

Install vue test globally

1. Enter the command npm install -g @vue/cli in Windows PowerShell

2. Open the specified folder to check whether the download is successful.

3. Enter the command vue -V in Windows PowerShell to check whether the installation is successful.

Other questions

If the following problems occur, you need to set ExecutionPolicy to RemoteSigned

solution:

(1) Run PowerShell in administrator mode and enter get-ExecutionPolicy. (Restricted, meaning prohibited)

(2) Input: set-ExecutionPolicy

Upgrade nvm

1. Download nvm-update.zip, unzip it and double-click nvm-update.exe, enter the version, click ok to start downloading (personal test stuck)

2. Directly download the new version of nvm and install it.

Notice:

1. The nvm installation path is the installed path and does not need to be modified. The default nodejs path is the C drive (modify according to the situation)

2. If nodejs has been installed on the current computer, or nvm has been used to control the nodejs version, you will still be prompted.

3. If you select the original installation path as the nodejs installation path, you will be prompted (select OK, the nodejs managed by nvm before still exists)

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Vue entry skill tree Home page Overview 38888 people are learning the system