Nodejs modify the image and cache path

After nodejs is installed, if you do not perform related configuration, there will be the following problems:

The first one: when executing an installation statement similar to: npm install express [-g] (the optional parameter -g, g stands for global installation), the installed module will be installed to C:\Users\username \AppData\Roaming\npm path, this will occupy the limited space of C drive.

Second: the download speed of mirroring using nodejs will be slower.

Next, I will briefly introduce the steps:

1. Replace the cache path

Step 1 : Create two new folders in the installation directory of node, named node_cache and node_global respectively

Step 2: Enter the following command in cmd, or give you a template:

npm config set prefix "D:\software\node\node_global"

npm config set cache "D:\software\node\node_cache"

npm config set prefix "D:\software\node\node_global"

npm config set cache "D:\software\node\node_cache"

The result is:

 Step 3 : Set environment variables

Step 4 : Create a new NODE_PATH, enter D:\software\node\node_global

 

Step 5: Set path

Step 6: Delete the previous settings

Step 7: Test whether the test is successful, use npm install cluster -g to test in the cmd running window

Step 8 : See the cluster file under D:\software\node\node_global

 

So far, the cache path has been modified successfully.

Second, replace the mirror

Step 1 : Enter the following command in the cmd window  npm config set registry https://registry.npm.taobao.org/

npm config set registry https://registry.npm.taobao.org/

Step 2 : Enter the  npm config get registry command

npm config get registry

 Step 3: Install Taobao mirror source

npm install -g cnpm --registry=https://registry.npm.taobao.org

Results view

So far, the modification of the image is complete.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/xgysimida/article/details/107638460