1. Installation environment
1. Native system: Windows 10 Professional Edition (64-bit) 2. Node.js: node-v8.9.4-x64.msi (64-bit)
Steps to install Node.js
1. Download the Node.js version corresponding to your own system, address: nodejs.org/zh-cn/ 2. Select the installation directory to install 3. Environment configuration 4. Test
3. Preliminary preparation
1. Introduction to Node.js
2. Download Node.js
4. start the installation
1. After the download is complete, double-click " node-v8.9.4-x64.msi " to start the installation:
2. Click the "Next" button
3. Select the installation directory and click the "Next" button
4. Select the installation item, here I choose the default, click the "Next" button
5. Click the "Install" button to start the installation
6. Wait for the installation to complete, click the "Finish" button to complete the installation
5. the installation is complete to view
1. Check if the installation is successful
A, node -v view node version
B, npm -v view the npm version
2. After the installation is complete, the file directory is as shown below
6. environment configuration
The environment configuration here mainly configures the path of the global module installed by npm and the path of the cache. The reason for the configuration is that it will be similar in the future: npm install express [-g] (the following optional parameters- g, g represents the meaning of global installation), the installed module will be installed in the path [C:\Users\Username\AppData\Roaming\npm], occupying the C drive space. For example: I want to put the path of the full module and the cache path in the folder where my node.js is installed, then create two folders [node_global] and [node_cache] in my installation directory as shown below:
1. Set the global directory and cache directory. After creating two empty folders, open the 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"
Reconfiguration: A. Delete the [C:\Users\yi081.npmrc] file and regenerate it. If .npmrc is not in this directory, search the C drive globally; B. Modify and compile the .npmrc file directly.
2. Set environment variables, "My Computer"-right click-"Properties"-"Advanced System Settings"-"Advanced"-"Environment Variables"
A. Enter the environment variable dialog box, create a new [NODE_PATH] under [System Variables], and enter [D:\SDE\Node8.9.4\node_modules]
B. Modify the [Path] under [User Variables] to [D:\SDE\Node8.9.4\node_global]
After the modification is completed, click the "OK" button.
After configuration, install a module to test, we install the most commonly used express module, open the cmd window, and enter the following command to install the module globally:
npm install express -g # -g
Note: If the -g parameter is not added during installation, the installed module will be installed in the current path. If the -g parameter is not added in the above example, the express module will be installed in the [node_modules] directory under C:\Users\yi081 Under the directory, if the directory does not exist, it will be automatically generated.
Finally, after consulting the online resources, it turns out that the command tool has been separated in the latest express version (project address: github.com/expressjs/g... ), so a command tool needs to be installed. The command is as follows:
npm install -g express-generator
Use express to create a project, enter the command: express helloworld
Go to the helloworld directory, command: cd helloworld
Load the node package manager, execute the command: npm install
Enter the address in the browser: http://localhost :3000/, visit our first node web page.