current position:Home>Node under window JS installation, environment configuration, setting Taobao image

Node under window JS installation, environment configuration, setting Taobao image

2022-05-15 02:15:51Long, ya

One 、Node.js Installation

Chinese net :Node.js

About Node.js Installation , Environment configuration , In fact, there are many good articles on setting image source on the Internet , Here we combine our own operation , Make a summary record of your practice .

Click on All installation packages Of Alibaba cloud image , Here's the picture
 Download Interface
If you need another version , Click on …/ Return to the parent folder . Here's the picture
node.js Full version Directory
Then you'll see from 0.1 Up to now, the installation directory of all versions , Pictured ( part )
node.js edition
Here I have chosen 10.19.0 Version of , The directory after clicking in is shown in the figure below . Directly find the suffix of the corresponding system digits as .msi Format installation package (32 Biting x86,64 Biting x64), Then click download .
noed.js Installation package format
Here is the installation . The default path specified during installation is C:\Program Files You can specify that node.js Installation path for . Then there is always next Until the installation is complete , Click... After installation finish Exit the installation interface .

Use node -v and npm -v test node Is the installation successful , If successful, the publication number will be printed , Here's the picture
 Install print version number

Two 、Node.js Environment configuration

If you choose .msi When installing the format , It will configure environment variables for you by default . If your installation path is E:\WebEnviroment\ In the system environment variable path The path is automatically added .

meanwhile node.js Default management system npm The global path and cache path of the package are in C:\Users\ Here is your username \AppData\Roaming Next . If you don't want to occupy C Disk space , Then we can configure new global path and cache path for him .

  1. stay node.js New in the installation directory node_global and node_cache Two new folders

  2. Alt+R Input cmd Open console , Run the following two instructions :

    npm config set prefix "E:\WebEnviroment\node\node_global"

    npm config set cache "E:\WebEnviroment\node\node_cache"

  3. Detect the situation after setting . Input npm config list. At the red box in the figure below cache and prefix The value of has become the path value we set .
    npm To configure list

  4. The following is to set the environment variable . My computer - Right click - attribute - Advanced system setup - senior - environment variable
     System environment variable interface
    After entering the interface , First find User variables -Path, Here's the picture
     Find the... Of the user variable Path
    Click edit ,( Note that if the previous value does not have a semicolon , Remember to add a semicolon first ) Add... At the end E:\WebEnviroment\node\node_global;. Here's the picture

    Here is System variables Editing . Click on newly build . A variable called NODE_PATH. Variable value is E:\WebEnviroment\node\node_global\node_modules

    Here's the picture
     The system variable increases NODE_PATH

    The configuration of this environment variable is completed .

  5. modify .npmrc
    Modify the installation E:\WebEnviroment\node\node_modules\npm\npmrc file , Change the default to ( newly added ):
    prefix=E:\WebEnviroment\node, If you don't make this change , be npm Running npm ls -g When , Still use the default path to find the installed global module ;

  6. test
    To test whether it works . Install one directly express modular , then node_global Whether there will be a node_modules, And include the... We installed express modular .

    Input npm install express -g
     Insert picture description here

    stay E:\WebEnviroment\node\node_global\node_modules There's one more express Folder , Prove that the module was installed successfully .
     Environment variable configuration succeeded

3、 ... and 、 Set up npm Mirror source for

​ There are many ways to set up a mirror source , Here are two kinds of :

1. adopt npm command

​ Input npm config set registry

​ After modification, you can test through this

npm config get registry
npm config get registry

2. Use nvm Switch source

npm isntall nrm -g Global installation

​ After installation , Input nrm ls View the current source . belt ==*== Indicates the currently used npm Source .
 View source
​ adopt nrm use taobao To specify the image source to use :
 Specify source
​ adopt nrm test npm To test speed :
 Test speed

Four 、 Install Taobao cnpm Mirror image ( Recommended installation )

​ In the case of domestic networks , It's better to use domestic image source , After all, the speed will be much faster .

​ Console input npm install -g cnpm --registry=

​ Enter for installation .

​ Input cnpm -v Check whether the information shown in the figure below is printed successfully
 see cnpm

5、 ... and 、 install node-sass Get stuck

Generally used in installation npm install install node-sass There will be installation failure , Stop there for a long time or pop up a failure prompt , Cause installation node_modules The folder is incomplete , In the use of gulp Unknown problems are likely to occur when building tools to package projects . It is recommended to delete it node_modules package , stay gulpfile.js Re run in the folder Directory cnpm install Installation . You can also set Taobao's sass Mirror source npm config set sass_binary_site, And then use npm install Installation .

copyright notice
author[Long, ya],Please bring the original link to reprint, thank you.

Random recommended