Steps to install Node.js
- Download the Node.js version corresponding to your system: https://nodejs.org/en/download/
- Select the installation directory to install
- Environment configuration
- test
Preliminary preparation
-
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. -
Download Node.js and
open the download link of the official website: https://nodejs.org/en/download/ :
start installation
- After the download is complete, double-click to start installing Node.js:
then just keep clicking Next; - Press the [win+R] key on the keyboard, enter cmd, then press Enter to open the cmd window:
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.
- 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.
- 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"
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!
- 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:
- 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
change: after change:
configuration is complete.