Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

Time:2021-9-15

Windows installation nodejs, NPM, yarn

1、 Nodejs download and installation

1. Download

1.1 open the browser to search nodejs

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

1.2. Download nodejs

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

2. Installation

Follow the instructions in the figure to complete the installation

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration
Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

So far, nodejs has been installed  ̄▽  ̄~*~

2、 NPM environment configuration

NPM is a package management tool of nodejs, which does not need to be downloaded separately

explain: the environment configuration here mainly configures the path of the global module installed by NPM and the path of the cache. It is necessary to configure because the installed module will be installed to [C: \ users \ username \ appdata \ roaming \ NPM] when executing the installation statement similar to: NPM install package [- G] (the following optional parameter – G, G represents the meaning of global global installation) The path occupies Disk C space.
for example: if I want to put the path where the global module is located and the cache path in the folder where I install nodejs, then create two folders [node_global] and [node_cache] under the folder where I install nodejs, as shown in the following figure

1. Find the location where nodejs is installed and click_ Two folders are added to the modeles peer directory (as shown in the following figure)

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

2. After creating two empty folders, open the CMD command window and enter the following command

//Set the installation location where NPM install package - G is executed
npm config set prefix "D:\soft\nodejs\node_global"
//Set cache location
npm config set cache "D:\soft\nodejs\node_cache"

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

3. Right click my computer and click Open attribute

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

4. Advanced system settings – > Advanced – > environment variables

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

5. Click new under system variable

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

6. Add the variable name node_ Path and variable value (node_modules folder of nodejs installation location)

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

7. Find the path in the user variable and enter

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

8. Perform the corresponding operation as shown in the figure

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

9. Here, the NPM environment is configured~

3、 Yarn download and environment configuration

Like NPM, yarn is a package management tool, but yarn downloads faster

1. Download

Download from the official website of yarn

1.1 download yarn using NPM
npm install yarn -g

The global downloaded package will be saved to the location specified in NPM above
【D:\soft\nodejs\node_global】

2. Yarn environment configuration

2.1 find the installation directory of yarn and add two folders at the same level of bin (as shown in the figure)

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

2.2 modify global directory
//Modify global installation directory
yarn config set global-folder "D:\soft\nodejs\node_global\node_modules\yarn\yarn_global"

//Modify global installation directory的bin目录位置
yarn config set prefix "D:\soft\nodejs\node_global\node_modules\yarn\yarn_global"    

//Modify global cache directory
yarn config set cache-folder "D:\soft\nodejs\node_global\node_modules\yarn\yarn_cache"

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

3. Add the global installation directory to the system environment variable

Figure 3-1

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

Figure 3-2

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

Figure 3-3

Nodejs download and installation, NPM environment configuration, yarn download and environment configuration

This concludes the tutorial~