Node.js installation and environment configuration

Steps to install Node.js

  1. Download the Node.js version corresponding to your system: https://nodejs.org/en/download/
  2. Select the installation directory to install
  3. Environment configuration
  4. test

Preliminary preparation

  1. Introduction to Node.js
    Simply put, Node.js is JavaScript running on the server. Node.js is a JavaScript runtime environment based on Chrome V8 engine. Node.js uses an event-driven, non-blocking I/O model to make it lightweight and efficient. Node.js package manager npm is the world's largest open source library ecosystem.

  2. Download Node.js and
    open the download link of the official website: https://nodejs.org/en/download/ :
    Insert picture description here

start installation

  1. After the download is complete, double-click to start installing Node.js:
    Insert picture description here
    then just keep clicking Next;
  2. Press the [win+R] key on the keyboard, enter cmd, then press Enter to open the cmd window:
    Insert picture description here

Environment configuration

Note: The environment configuration here mainly configures the path of the global module installed by npm and the path of the cache. The reason for this configuration is that it will be similar in the future: npm install express [-g] (optional parameters later -g, g represents the meaning of global installation), the installed module will be installed to the path [C:\Users\Username\AppData\Roaming\npm], occupying the C drive space.

  1. Create the following two folders under the nodejs installation path:
    ① node_global: used to store global modules
    ② node_cache: used to store the cache of the downloaded package.
    Insert picture description here
  2. Open the terminal and enter the following two commands to run:
# 设置全局模块存放路径
npm config set prefix "C:\Program Files\nodejs\node_global" 
# 设置缓存文件夹
npm config set cache "C:\Program Files\nodejs\node_cache" 

Insert picture description here

Note: Create the above two folders to avoid
installing the global module under C:\Users\username\AppData\ under Roaming\npm when using npm to download the global module in the future, which takes up too much space!

  1. Configure environment variables:
    Create a new variable named "NODE_PATH" in Environment Variables -> System Variables, with a value of "C:\Program Files\nodejs\node_modules", as shown below:
    Insert picture description here
  2. Finally edit the Path in the user variable and change the path of the corresponding npm to: D:\Program Files\nodejs\node_global, as follows:
    before
    Insert picture description here
    change: after change:
    Insert picture description here
    configuration is complete.

Guess you like

Origin blog.csdn.net/Jessieeeeeee/article/details/112170250