【Tools official website】
Node.js : http://nodejs.cn/
【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
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
npm config set prefix "C:\Program Files\nodejs\node_global" npm config set cache "C:\Program Files\nodejs\node_cache"
set NODE_PATH=your\directory\to\node_modules;%NODE_PATH%
(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. \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.