Nodejs global (npm, cnpm, yarn) and basic cache configuration, just one article
install nodejs
Official download address
It is recommended to pick a common disk and name it nodejs. The path I configured is D:\nodejs
, the following path is myself记得修改到自己配置的位置
above sea level
After installing nodejs, we have npm, but it is too slow to download resources, so we need to configure cnpm and yarn, first check whether our npm environment is correct, open cmd and run npm -v
C:\Users\admin>npm -v
6.14.6
Then configure the location of the global package and cache. I configure all the nodejs I created in the D drive ( 自己记得修改成自己想要的位置
), which is convenient for management. cmd executes the following two sentences successively.
npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"
cnpm
Once configured, start installing cnpm globally
npm install -g cnpm --registry=https://registry.npm.taobao.org
After installation, run cnpm -v to see if cnpm can be recognized
C:\Users\admin>cnpm -v
cnpm@6.1.1 (D:\nodejs\node_global\node_modules\cnpm\lib\parse_argv.js)
npm@6.14.8 (D:\nodejs\node_global\node_modules\cnpm\node_modules\npm\lib\npm.js)
node@12.18.4 (D:\nodejs\node.exe)
npminstall@3.28.0 (D:\nodejs\node_global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=D:\nodejs\node_global
win32 x64 10.0.19041
registry=https://r.npm.taobao.org
yarn
We can download the yarn with cnpm, which is also installed globally.
cnpm install yarn -g
Set Taobao source
yarn config set registry https://registry.npm.taobao.org
Modify the location and cache location of the global package installed with yarn, and run ( 记得修改位置为自己的配置位置
) successively
yarn config set global-folder "D:\nodejs\yarn\global"
yarn config set cache-folder "D:\nodejs\yarn\cache"
exception handling
If it prompts that a command cannot be recognized as an internal or external command, a runnable program or batch file during the running process, or the environment is not
properly configured, go to the system Path variable of the computer and add the corresponding installation location of the command.