Windows installation nodejs

First, install node.js

1. node.js official website to download and install the tool, choose the installation path here to the D drive, D: \ Program Files \ nodejs

 After installation, enter the following command at the command line to test whether the installation is successful, there will be the correct version number

asl -v

2. Change the original environment variables,

  (1) Configuration npm global module storage path and cache path, for example, two folders in your home directory NodeJS, establish "node_global" and "node_cache" two folders in NodeJs, enter the following command to change npm configuration

 

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

 

(2) add the system variables in the system environment variables NODE_PATH, enter the path D: \ Program Files \ nodejs \ node_global \ node_modules, after the installation modules are mounted to the changed path  

(3) at the command line command attempting to install the express (Note: "- g" means that this parameter is attached to the global directory, which is above said set "D: \ Program Files \ nodejs \ node_global" inside.)

npm install express -g

After installation you can see. \ Node_global \ node_modules \ express has content

 

  (4) in the command input node to enter the edit mode line, enter the following code tests whether the normal loading module:

require('express')

 

Assuming that success, you can see the output. Suppose an error, check the path of NODE_PATH.

Second, the installation Taobao npm (cnpm)

 1. Install cnpm

   (1) Enter the following command

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

   (2) Input cnpm -v input is normal, there will certainly be wrong.

cnpm -v

   (3) Add the contents of system variables path

  Because cnpm will be installed to D: \ Program Files nodejs under \ \ node_global, and the system variable path does not include the path. Add the path to the system under normal use cnpm variable path; disposed below

 Optimization: define NODE_HOME variable replacement in the Path

Guess you like

Origin www.cnblogs.com/kevinlucky/p/12638717.html