Node.js installation (novice)

node.js Installation step by step tutorial

download

1、 Download installation package
Node.js Official website download :
nodejs.org/zh-cn/download/

Select the package corresponding to the operating system :

 Please add a picture description

Download complete , The installation package is as follows :

install

2、 install
Open the installation , The next step in the fool’s pose is :

The installation location can be set by default , But the default is C disc , Easy to occupy the system disk , If the default installation location , The following path doesn’t have to be changed .

I personally choose the installation location , Mounted on D Under the plate :D:Nodejs install

Installation successful , The folder structure is as follows , In the above installation process, the environment variables have been automatically configured and installed npm package , At this point, you can execute node -v and npm -v View separately node and npm Version number of :

For example, execute the result at the command prompt :

C:UsersLenovo>node -v
v14.17.5
C:UsersLenovo>npm -v
6.14.14

To configure Node.js Environment variables of

The following is to choose the default installation path , Further changes are required , If it is installed in the default path, there is no need to change


If an error is reported above , It means that the environment variables are not configured properly

Then you have to add environment variables manually :

This computer -> Right click attribute -> Click on Advanced system setup

 Please add a picture description

Click on environment variable

 Please add a picture description

Choose Path route Go in and edit

 Please add a picture description

Copy install Node.js Installation path for

 Please add a picture description

 Please add a picture description

To configure npm

3、 To configure npm Path and cache when installing global modules cache The path of
Because in execution for example npm install webpack -g When you command global installation , The module will be installed in by default C:Users user name AppDataRoaming The next path npm and npm_cache in , Inconvenient to manage and occupy C Disk space , As shown in the figure below :

So configure the custom global module installation directory here , stay node.js Create two new folders under the installation directory node_global and node_cache, And then in cmd The following two commands are executed under the command :

npm config set prefix "D:Nodejs install node_global"
npm config set cache "D:Nodejs install node_cache"

Execution results :

 Please add a picture description

notes : Be sure to create those two folders first , Otherwise, there will be an error reported above

Set up npm Environment variables of

If it is the default installation path , The system will configure its own environment variables , But if you install in a custom path , You have to change it manually

Successful implementation . And then in the environment variable -> Create a new variable in the system variable named “NODE_PATH”, The value is “D:Nodejs install node_modules”, Here’s the picture :

This computer – > Left mouse button -> attribute ->

 Please add a picture description

Click on Advanced system setup

 Please add a picture description

Click on environment variable

 Please add a picture description

Click on newly build

 Please add a picture description

Input Variable name and A variable's value

NODE_PATH
D:Nodejs install node_modules

 Please add a picture description

Copy path ( That is… Under the installation path node_modules Under the folder )

 Please add a picture description

Add success

 Please add a picture description

spot determine

Finally, edit the in the user variable Path, Set the default C:Users user name AppDataRoamingnpm Change to the following figure :

 Please add a picture description

Select to edit

 Please add a picture description

Copy the path

 Please add a picture description

Configuration complete .

Read more here: Source link