Node.js environment configuration, nmswitch


preparation in advance

1. Introduction to node.js
In short, node.js is JavaScript running on the server side. Node.js is a JavaScript running environment based on chrome V8 engine. Node.js uses an event driven, non blocking I / O model to make it lightweight and efficient. Node.js package manager NPM is the largest open source library ecosystem in the world.
2. Download node.js
I download node-v11.3.0-x64.msi here.

Start installation

1. After downloading, double-click “node-v11.3.0-x64.msi” to install node.js


Click the [next] button all the way, and select the installation directory by yourself (it is not recommended to install it on Disk C)

So far, node.js has been installed. You can first test whether the installation is successful, and then configure the environment
Press the [win + R] key on the keyboard, enter CMD, and then enter to open CMDgamewindow

Note here: the new version of node.js has its own NPM, which will be installed together when node.js is installed. The function of NPM is to manage the packages that node.js depends on, which can also be understood as the things that node.js needs to install / uninstall

Environment configuration

Note: the environment configuration here mainly configures the path of the global module installed by NPM and the path of the cache. The reason for the configuration is that when the installation statement similar to NPM install express [- g] (optional parameter – G, G stands for global global installation) is executed in the future, The installed module will be installed in the path of [C: users, user name, appdata, roaming, NPM] to occupy the space of disk C.

After creating two empty folders, open the CMD command window and enter

npm config set prefix “D:\Develop\nodejs\node_global”
npm config set cache “D:\Develop\nodejs\node_cache”、


After configuration, it is recommended to replace the NPM image source. Reason: because the node installation plug-in is downloaded from a foreign server, it is greatly affected by the network, slow and may be abnormal. So if the NPM server is in China, for example:, that is to say, we can use the server in China for node installation.
Similarly, under the command of CMD, enter:

npm config set registry –global
npm config set disturl –global

Finally, after installing a module for testing, we will install the most commonly used express module and open the CMD window,
Enter the following command to install the module globally:

NPM install Express – G # – G means global installation