Play with the system | node.js version management tool nvm installation and setting detailed process

Recently, I wanted to add a watermark to the pictures in the blog posts, but I didn’t want to use separate software to add watermarks every time. I thought that picgo seemed to have a watermark plug-in, picgo-plugin-watermark, so I installed it excitedly, but when I installed it, I found that… No matter how I pretended, there was no response. The specific manifestation is that after installation, it shows that it has been installed. You can open the plug-in list but cannot find the watermark plug-in. Even restarting picgo does not work.

Open the picgo plug-in directory C:\Users\Administrator\AppData\Roaming\PicGo and use the command npm install picgo-plugin-watermark. Direct installation is still the same. Download the plug-in directly locally. The import also doesn’t work, and I have no choice but to look at the issues of the plug-in project and find that many people have the same problem. It seems to be in conflict with the rename plug-in and compression plug-in. After uninstalling these two plug-ins and reinstalling them, the same problem persists, and I see Check it out, the author of version 1.1.0 specifically solved the problem of plug-in conflicts.

At this time, I found a reply saying that the installation was successful after downgrading the node version to 10.24.0. In the spirit of not tossing it, you will not die, so let’s downgrade it. So far, there is today’s article, which records the installation and setup process of nvm, the node.js version management software under Windows.

Install nvm management tool

If you have installed node.js before, please uninstall it in the control panel, then delete the previous node installation directory, and delete the environment variables you previously configured. It is best to restart the machine and then install nvm to avoid a lot of trouble.

Installation

First turn off the anti-virus software, otherwise a warning will pop up! Then download the latest installation package from the official website https://github.com/coreybutler/nvm-windows/releases, decompress it to get nvm-setup.exe, and run this file to install. (See the picture below for the installation process)

  • Check I accept the agreement and click Next;
  • Select the nvm installation path (it must be placed in the root directory of a certain partition, and the directory name cannot contain Chinese characters, spaces, or symbols, otherwise an error will be reported) and click Next ;
  • Select the node installation path (it doesn’t matter, but try to put it at the same level as the nvm directory) and click Next;
  • Click Install to install, then finish to complete the installation.

Install and switch node.js version

Verify nvm installation

WIN + R to open the run, enter cmd, open the command line, enter nvm to verify, if there is no problem, the following command explanation will be returned.

C:\Users\Administrator>nvm

Running version 1.1.8.

Usage:

  nvm arch : Show if node is running in 32 or 64 bit mode.
  nvm current : Display active version.
  nvm install <version> [arch] : The version can be a specific version, "latest" for the latest current version, or "lts" for the
                                 most recent LTS version. Optionally specify whether to install the 32 or 64 bit version (defaults
                                 to system arch). Set [arch] to "all" to install 32 AND 64 bit versions.
                                 Add --insecure to the end of this command to bypass SSL validation of the remote download server.
  nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
  nvm on : Enable node.js version management.
  nvm off : Disable node.js version management.
  nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
                                 Set [url] to "none" to remove the proxy.
  nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
  nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
  nvm uninstall <version> : The version must be a specific version.
  nvm use [version] [arch] : Switch to use the specified version. Optionally use "latest", "lts", or "newest".
                                 "newest" is the latest installed version. Optionally specify 32/64bit architecture.
                                 nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
  nvm root [path] : Set the directory where nvm should store different versions of node.js.
                                 If <path> is not set, the current root will be displayed.
  nvm version : Displays the current running version of nvm for Windows. Aliased as v.

Next, we enter the command nvm list available to view the available node.js version numbers. If you know which version you want to download, this step is not required. At this time, domestic users must also set the mirror address, otherwise an error will be reported.

C:\Users\Administrator>nvm list available

| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|---- ----------|
| 16.10.0 | 14.17.6 | 0.12.18 | 0.11.16 |
| 16.9.1 | 14.17.5 | 0.12.17 | 0.11.15 |
| 16.9.0 | 14.17.4 | 0.12.16 | 0.11.14 |
| 16.8.0 | 14.17.3 | 0.12.15 | 0.11.13 |
| 16.7.0 | 14.17.2 | 0.12.14 | 0.11.12 |
| 16.6.2 | 14.17.1 | 0.12.13 | 0.11.11 |
| 16.6.1 | 14.17.0 | 0.12.12 | 0.11.10 |
| 16.6.0 | 14.16.1 | 0.12.11 | 0.11.9 |
| 16.5.0 | 14.16.0 | 0.12.10 | 0.11.8 |
| 16.4.2 | 14.15.5 | 0.12.9 | 0.11.7 |
| 16.4.1 | 14.15.4 | 0.12.8 | 0.11.6 |
| 16.4.0 | 14.15.3 | 0.12.7 | 0.11.5 |
| 16.3.0 | 14.15.2 | 0.12.6 | 0.11.4 |
| 16.2.0 | 14.15.1 | 0.12.5 | 0.11.3 |
| 16.1.0 | 14.15.0 | 0.12.4 | 0.11.2 |
| 16.0.0 | 12.22.6 | 0.12.3 | 0.11.1 |
| 15.14.0 | 12.22.5 | 0.12.2 | 0.11.0 |
| 15.13.0 | 12.22.4 | 0.12.1 | 0.9.12 |
| 15.12.0 | 12.22.3 | 0.12.0 | 0.9.11 |
| 15.11.0 | 12.22.2 | 0.10.48 | 0.9.10 |

This is a partial list. For a complete list, visit https://nodejs.org/download/releases

Set nvm mirror to improve download speed

  • Enter the command directly (remember the trailing slash)
nvm node_mirror http://npm.taobao.org/mirrors/node/
nvm npm_mirror https://npm.taobao.org/mirrors/npm/
  • Or modify the setting.txt file in the nvm installation directory and add
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
  • The mac and linux versions of nvm do not have the node_mirror & npm_mirror command . The way to set the download node mirror address is
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist

Replace the address after the equal sign with the Taobao mirror (
https://npm.taobao.org/mirrors/node) will do it

Install node.js

Then enter the command nvm install version number (For example, I want to install 10.24.0, so enter: nvm install 10.24.0, if you want To install the latest version, use the command: nvm install latest ) to install the corresponding version of node, and the corresponding version of npm will be automatically installed. After the installation is complete, you can enter the commands node -v and npm -v respectively to check node.js and the corresponding npm Whether the installation is successful, if the version number can be displayed, it means the installation is successful;

Switch node version

  • After installation, enter the command nvm list to view all the node.js version numbers you have installed, as well as the currently selected node.js running version;
  • Enter the command nvm use version number (For example: nvm use 10.24.0) to select the Node.js version you are using locally. Use this command line to customize your own You need to switch the node.js version to run at will;

Garbled error when switching node version

At this time, a problem occurred. When I used the command to switch versions, a problem occurred. It prompted exit status 1: a string of garbled characters, as shown in the picture below.

After searching around on the Internet, I found that this problem is because the nvm installation directory contains spaces, Chinese characters, symbols, etc. It can be solved by reinstalling nvm to a pure English directory in the root directory, but I did not have this problem when I installed it ( I would like to thank you for the good habit I have developed all the time. I never set the software directory to Chinese, etc. After all, Windows was originally developed by foreigners), and then I thought it might be a permission issue with the node directory. Setting After that, the error still occurs. Finally, I found someone in the nvm project issues who replied that I had to switch to C:\Windows\system32 and then switch the version and it was OK. I tried it but the error remained. At this time, I had an idea. Could it be a permissions issue? Then open cmd.exe as an administrator and enter nvm use 10.24.0 again. At this time, it finally shows that the switch is successful (see the picture below).

Remember here, after installing the new version of node, you need to re-install npm globally npm install npm -g. Of course, remember to set up the Taobao mirror.

npm install -g cnpm --registry=https://registry.npm.taobao.org
// Sometimes this will still fail and the image has not changed. You can use the following command to modify it.
npm config set registry=http://registry.npm.taobao.org

Uninstall node

If you want to delete a certain node.js version, enter the command line nvm uninstall version number (for example: nvm uninstall 10.24.0) to delete the corresponding version.

Postscript

At this point, the installation and configuration of nvm are complete. It will be much more convenient to use nvm to install and manage node versions, saving a lot of trouble. Finally, although the node downgrade was successful, the installation of PicGo’s watermark plug-in was not successful. If anyone has a solution, please leave a message to exchange.