nodejs installation and environment configuration - Windows

0. Common problems encountered during installation

Visit: https://blog.csdn.net/weixin_52799373/article/details/125718587?spm=1001.2014.3001.5502

1. Download node.js

Download link: https://nodejs.org/en/

2. Install

2.1 installation






In fact, it is the next step without thinking. In the third step, you can choose a custom directory. My development tools are all placed in develop.

2.2 Testing

node -v View the version of node
npm -v View the version of npm (the new version of node installation comes with npm installed)

3. Configure environment variables

3.1 Configure the globally installed module path and cache path

Create folder directory

  • In the nodejs root directory, create node_globala node_cachefolder

-Administrator status- Open CMD and configure the path: (Note that you must run CMD as an administrator!!! Change the path to your own path, don’t copy it without thinking!!!)

npm config set prefix "E:\develop\nodejs\node_global"
npm config set cache "E:\develop\nodejs\node_cache"

3.2 Configure environment variables

3.2.1 Find the computer environment variable location

win10&win11: Right click on this computer - properties - advanced system settings - advanced - environment variables

Win11 can also: point settings - system - about - advanced system settings - advanced - environment variables

3.2.2 Create NODE_HOME variable

The variable value is the nodejs address
insert image description here

3.2.3 Select Path in the system variable, modify and add the following properties:

  • Revise:

insert image description here

  • add node_global, node_cache:
    insert image description here

4. Test

Install the most commonly used express modules globally for testing.
The command is as follows:

npm install express -g

View installation results:

5. Configure Taobao mirror globally

Note that you must run CMD as an administrator! ! !

npm config set registry https://registry.npm.taobao.org
# 安装 cpm (按需安装)
npm install -g cnpm

View configuration:npm config ls
insert image description here

6. Install webpack globally

npm install webpack -g

Finish

Guess you like

Origin blog.csdn.net/weixin_52799373/article/details/123840137