[Experience Sharing] Install nodejs under windows

1. Download the installation package

Visit address:
https://nodejs.org/en/download/
Insert picture description here

Choose the LTS version and choose the even-numbered NodeJS version, such as 8, 10, because the even-numbered version is a long-term stable version and has better compatibility. The NodeJS iteration version is too fast. It is no problem to choose an even version even if it is version 8.0. It is said that it usually takes up to 18 months to maintain and expand. The odd-numbered version number is said to be the development version before the even-numbered stable version.

Two, installation

  1. Double click to run the installation package
    Insert picture description here
    Insert picture description here
  2. Select the installation path, the default is C drive, I chose D drive here
    Insert picture description here
  3. Default
    Insert picture description here

Insert picture description here
Insert picture description here

Three, check the version

  1. Win + R, enter cmd, dos open command, the input node -vview the version number NodeJS
    Insert picture description hereInsert picture description here
  2. Open the installation directory to view the folder
    Insert picture description here
    (the new version of Node.js already comes with npm, and it will be installed together when you install Node.js. The role of npm is to manage the packages that Node.js depends on, and it can also be understood as used to install/uninstall Node. .js needs to be installed)

Four, environment variable configuration

The environment configuration mainly configures the path of the global module installed by npm and the path of the cache cache. The reason for the configuration is that it will be similar in the future: npm install express [-g] (the optional parameters -g, g later) When the installation statement 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 I installed node.js, then create two folders [node_global] and [node_cache] under my installed folder [D:\nodejs] As shown below:
Insert picture description here

  1. In the current folder, long press Shift + right mouse button to open the cmd command line
    Insert picture description here

  2. Enter the following command to set

    npm config set prefix "D:\NodeJS\node_global"
    npm config set cache "D:\NodeJS\node_cache"
    12
    
  3. Set environment variables, close the cmd window, "My Computer"-right click-"Properties"-"Advanced System Settings"-"Advanced"-"Environment Variables"
    Insert picture description here

  4. Enter the environment variable dialog box, create a new [NODE_PATH] under [System Variables], enter it D:\NodeJS\node_global\node_modules, and modify the [Path] under [User Variables] toD:\NodeJS\node_global
    Insert picture description here
    Insert picture description here
    Insert picture description here
    Insert picture description here

Five, test

After the configuration, install a module to test, we install the most commonly used express module, open the cmd window,
enter the following command to install the module globally:

npm install express -g     # -g是全局安装的意思

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44704985/article/details/113971206