Install Node.js and cnpm

1. Install Node.js

1. Download

Node.js official website download
Download the corresponding installation package according to your own system (I am Windows 10 64-bit here, so I choose to download the first installation package)

 2. Then click Install and choose the path you want to install. Here I choose: D:\Program Files\nodejs and the installation is complete.

3. window+R , enter cmd , open the command prompt window, enter:

3. Change the original environment variables

1. First configure the storage path of npm’s global modules and the path of the cache. Here I choose to put them in: D:\Program Files\nodejs
and enter the following commands in turn: ( note that the path should be changed to your own path )

npm config set prefix "D:\Program Files\nodejs\node_global"
npm config set cache "D:\Program Files\nodejs\node_cache"

 2. Enter the following command on the command line to install express. express is the only web framework officially recommended by node, and provides many basic and convenient functions. (Note: "-g" means to install to the global directory, which is the node_global set above)

npm install express -g

 You can see that there is express under node_global/node_modules, as shown in the figure:

3. Add NODE_PATH to the system environment variable, and the input path is: D:\Program Files\nodejs\node_global\node_modules
The operation is as follows: Right-click on my computer, open Properties->Advanced System Settings->Environment Variables->New (system variable Next)->Enter the variable name NODE_PATH->Variable value: Enter the above path through "Browse directory" and confirm. 

 

Set the mirror as the latest Taobao

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

If you need to restore to the original official address, you only need to execute the following command:

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

Check whether the installation is successful:

 npm config get registry

 4. Install cnpm

1. To install cnpm, enter the following command

npm install -g cnpm --registry=http://registry.npmmirror.com

When using node version 14, you can execute the following command to install the specified version of cnpm

npm install -g [email protected] --registry=https://registry.npm.taobao.org

Guess you like

Origin blog.csdn.net/GL666/article/details/130513615