Install npm and cnpm (Windows) Install npm and cnpm (Windows)

Install npm and cnpm (Windows)

【Tools official website】

Node.js : http://nodejs.cn/

Taobao NPM:  https://npm.taobao.org/

 

【installation steps】

1. Install node.js

1. Go to the node.js official website to download and install the tool, where the installation path is selected to the D drive, D:\Program Files\nodejs

 After the installation is complete, enter the following command on the command line to test whether the installation is successful, and the version number will appear correctly

1
npm -v

 

2. Change the original environment variables,

  (1) We need to configure the storage path of the global module of npm and the path of the cache. For example, if I want to put the above two folders in the main directory of NodeJS, I will create two "node_global" and "node_cache" under NodeJs. folder, enter the following command to change the npm configuration

1
2
npm config  set  prefix  "C:\Program Files\nodejs\node_global"
npm config  set  cache  "C:\Program Files\nodejs\node_cache"

 

  (2) Add the system variable NODE_PATH to the system environment variable, enter the path D:\Program Files\nodejs\node_global\node_modules, and the modules installed after that will be installed in the changed path  

  (3) Enter the following command on the command line to try to install express (Note: the parameter "-g" means to install it in the global directory, that is, in the "D:\Program Files\nodejs\node_global" set above.)

1
npm install express -g

 After installation, you can see that .\node_global\node_modules\express already has content

  (4) Enter node on the command line to enter the editing mode, and enter the following code to test whether the module can be loaded normally:

1
require( 'express' )

 Assuming success, you can see output. Assuming an error, check the path in NODE_PATH.

 

2. Install Taobao npm (cnpm)

 1. Install cnpm

   (1) Enter the following command

1
npm install -g cnpm --registry=https: //registry.npm.taobao.org

   (2) Whether the input of cnpm -v is normal, there will definitely be an error here.

1
cnpm -v

 

   (3) Add the content of the system variable path

  Because cnpm will be installed under D:\Program Files\nodejs\node_global, and the system variable path does not contain this path. Add this path under the system variable path to use cnpm normally.

 

Reference article: [NetEase Blog] NodeJS, NPM installation and configuration steps (windows version)

【Tools official website】

Node.js : http://nodejs.cn/

Taobao NPM:  https://npm.taobao.org/

 

【installation steps】

1. Install node.js

1. Go to the node.js official website to download and install the tool, where the installation path is selected to the D drive, D:\Program Files\nodejs

 After the installation is complete, enter the following command on the command line to test whether the installation is successful, and the version number will appear correctly

1
npm -v

 

2. Change the original environment variables,

  (1) We need to configure the storage path of the global module of npm and the path of the cache. For example, if I want to put the above two folders in the main directory of NodeJS, I will create two "node_global" and "node_cache" under NodeJs. folder, enter the following command to change the npm configuration

1
2
npm config  set  prefix  "C:\Program Files\nodejs\node_global"
npm config  set  cache  "C:\Program Files\nodejs\node_cache"

 

  (2) Add the system variable NODE_PATH to the system environment variable, enter the path D:\Program Files\nodejs\node_global\node_modules, and the modules installed after that will be installed in the changed path  

  (3) Enter the following command on the command line to try to install express (Note: the parameter "-g" means to install it in the global directory, that is, in the "D:\Program Files\nodejs\node_global" set above.)

1
npm install express -g

 After installation, you can see that .\node_global\node_modules\express already has content

  (4) Enter node on the command line to enter the editing mode, and enter the following code to test whether the module can be loaded normally:

1
require( 'express' )

 Assuming success, you can see output. Assuming an error, check the path in NODE_PATH.

 

2. Install Taobao npm (cnpm)

 1. Install cnpm

   (1) Enter the following command

1
npm install -g cnpm --registry=https: //registry.npm.taobao.org

   (2) Whether the input of cnpm -v is normal, there will definitely be an error here.

1
cnpm -v

 

   (3) Add the content of the system variable path

  Because cnpm will be installed under D:\Program Files\nodejs\node_global, and the system variable path does not contain this path. Add this path under the system variable path to use cnpm normally.

 

Reference article: [NetEase Blog] NodeJS, NPM installation and configuration steps (windows version)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326275852&siteId=291194637