1. Installation environment

2. Node.js: node-v8.9.4-x64.msi (64-bit)

Install Node.js

1. Download the node. js version for your own system at nodejs.org/zh-cn/. 2

Three, early preparation

1. Introduction to Node.js

Node.js® is a JavaScript runtime based on the Chrome V8 engine. Node.js uses an efficient, lightweight event-driven, non-blocking I/O model. Its package ecosystem, NPM, is currently the largest open source library ecosystem in the world.

2. Download Node.js

Official Address:nodejs.org/en/ 或 nodejs.org/zh-cn/I downloaded node-v8.9.4-x64.msi, as shown below:

4. Start installation

1. After downloading, double-click”Node – v8.9.4 – x64. Msi“, start installation:

Click the “Next” button

3. Select the installation directory and click “Next”

4. Select the installation options, here I choose the default, and click the “Next” button

5. Click “Install” button to start the installation

6. Wait for the installation to complete and click “Finish” to complete the installation

5. Check after installation

1. Check whether the installation is successful

A. Node -v View the node version

B. NPM -v View the NPM version

2. After the installation, the file directory is shown below

Vi. Environment configuration

The environment configuration here is mainly to configure the path of the global module installed by NPM and the path of the cache cache. NPM Install Express [-g] (optional -g, g indicates the global installation), the installed module will be installed in the [C: Users\ User name \AppData\Roaming\ NPM] path, occupy disk C space. For example, IF I want to put the entire module path and cache path in my node.js installation folder, I will create two folders [node_global] and [node_cache] under my installation directory as shown below:

1. Set the global directory and cache directory. After creating two empty folders, open CMD command window and enter

NPM config set prefix “D:\SDE\Node8.9.4\node_global”

NPM config set cache" D:\SDE\ node8.9.4\ node_cache"

Reconfigure: A, delete [C: Users\yi081. NPMRC] file and regenerate. If.npmrc is not in this directory, do a global search on drive C; B, directly modify compile. NPMRC file.

2, set environment variables, “My computer” – right-click – “Properties” – “Advanced System Settings” – “Advanced” – “Environment variables”

D:\SDE\ node8.9.4\ node_modules D:\SDE\ node8.9.4\ node_modules

D:\SDE\ node8.9.4\ node_global; D:\SDE\ node8.9.4\ node_global

When the modification is complete, click “OK”.

Seven, test,

After the configuration, install a Module test, we will install the most commonly used Express module, open CMD window, enter the following command to install the module globally:

  NPM install express -g # -g

Note: If the -g parameter is not used, the installed module will be installed in the current path. If the -g parameter is not used, the express module will be installed in the [node_modules] directory of C:\Users\yi081. If the directory does not exist, it will be automatically generated.

Finally, after checking online resources, it turns out that the command tool is separated from the latest Express version (project address :github.com/expressjs/g…). , so you also need to install a command tool, command is as follows:

npm install -g express-generator

To create a project using Express, enter the command Express HelloWorld

Go to the helloWorld directory and run CD HelloWorld

To load the Node package manager, run NPM install

Enter the address http://localhost:3000/ in your browser to visit our first Node Web page.