官方网址:https://nodejs.org/en
下载网址:https://nodejs.org/dist/v20.9.0/node-v20.9.0-x64.msi
下载完毕点击安装包 然后一路默认选项 Next …
npm -v
node -v
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.2.3
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>
# 获取下载依赖包路径
npm config get prefix
# 获取缓存路径
npm config get cache
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.1.0
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>npm config set prefix="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global"
C:\Users\liuzhengquan.cn>npm config set cache="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache"
C:\Users\liuzhengquan.cn>npm config get cache
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache
C:\Users\liuzhengquan.cn>npm config get prefix
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
C:\Users\liuzhengquan.cn>
cmd 中执行任意 npm 依赖包 这里以 express 演示
npm install express -g
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.1.0
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>npm config set prefix="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global"
C:\Users\liuzhengquan.cn>npm config set cache="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache"
C:\Users\liuzhengquan.cn>npm config get cache
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache
C:\Users\liuzhengquan.cn>npm config get prefix
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
C:\Users\liuzhengquan.cn>npm install express -g
changed 62 packages in 9s
11 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>
npm config get registry
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.1.0
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>npm config set prefix="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global"
C:\Users\liuzhengquan.cn>npm config set cache="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache"
C:\Users\liuzhengquan.cn>npm config get cache
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache
C:\Users\liuzhengquan.cn>npm config get prefix
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
C:\Users\liuzhengquan.cn>npm install express -g
changed 62 packages in 9s
11 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npmjs.org/
C:\Users\liuzhengquan.cn>
npm config set registry https://registry.npm.taobao.org
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.1.0
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>npm config set prefix="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global"
C:\Users\liuzhengquan.cn>npm config set cache="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache"
C:\Users\liuzhengquan.cn>npm config get cache
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache
C:\Users\liuzhengquan.cn>npm config get prefix
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
C:\Users\liuzhengquan.cn>npm install express -g
changed 62 packages in 9s
11 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npmjs.org/
C:\Users\liuzhengquan.cn>npm config set registry https://registry.npm.taobao.org
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npm.taobao.org
C:\Users\liuzhengquan.cn>
npm config set registry https://registry.npmjs.org/
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm -v
10.1.0
C:\Users\liuzhengquan.cn>node -v
v20.9.0
C:\Users\liuzhengquan.cn>npm config set prefix="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global"
C:\Users\liuzhengquan.cn>npm config set cache="C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache"
C:\Users\liuzhengquan.cn>npm config get cache
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\cache
C:\Users\liuzhengquan.cn>npm config get prefix
C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
C:\Users\liuzhengquan.cn>npm install express -g
changed 62 packages in 9s
11 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npmjs.org/
C:\Users\liuzhengquan.cn>npm config set registry https://registry.npm.taobao.org
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npm.taobao.org
C:\Users\liuzhengquan.cn>npm config set registry https://registry.npmjs.org/
C:\Users\liuzhengquan.cn>npm config get registry
https://registry.npmjs.org/
C:\Users\liuzhengquan.cn>
npm install -g cnpm
cnpm -v
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm install -g cnpm
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
changed 457 packages in 8s
54 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>cnpm -v
cnpm@9.2.0 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\lib\parse_argv.js)
npm@9.9.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npm\index.js)
node@20.9.0 (C:\Program_Files\Node\x64\20.9.0\node.exe)
npminstall@7.11.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
win32 x64 10.0.22631
registry=https://registry.npmmirror.com
C:\Users\liuzhengquan.cn>
cnpm config get registry
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm install -g cnpm
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
changed 457 packages in 8s
54 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>cnpm -v
cnpm@9.2.0 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\lib\parse_argv.js)
npm@9.9.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npm\index.js)
node@20.9.0 (C:\Program_Files\Node\x64\20.9.0\node.exe)
npminstall@7.11.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
win32 x64 10.0.22631
registry=https://registry.npmmirror.com
C:\Users\liuzhengquan.cn>cnpm config get registry
https://registry.npmmirror.com/
C:\Users\liuzhengquan.cn>
cnpm config set registry https://registry.npm.taobao.org
Microsoft Windows [版本 10.0.22631.2428]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liuzhengquan.cn>npm install -g cnpm
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
changed 457 packages in 8s
54 packages are looking for funding
run `npm fund` for details
C:\Users\liuzhengquan.cn>cnpm -v
cnpm@9.2.0 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\lib\parse_argv.js)
npm@9.9.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npm\index.js)
node@20.9.0 (C:\Program_Files\Node\x64\20.9.0\node.exe)
npminstall@7.11.1 (C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Program_Files\Environment_Dependency_Cache_Package\Node\Repository\global
win32 x64 10.0.22631
registry=https://registry.npmmirror.com
C:\Users\liuzhengquan.cn>cnpm config get registry
https://registry.npmmirror.com/
C:\Users\liuzhengquan.cn>cnpm config set registry https://registry.npm.taobao.org
C:\Users\liuzhengquan.cn>cnpm config get registry
https://registry.npm.taobao.org/
C:\Users\liuzhengquan.cn>
# cnpm install 需要下载的依赖包名称
# 比如
# npm install express -g 改使用cnpm 国内镜像则为这样 cnpm install express -g
npm install -g
npm uninstall
npm uninstall <@scope/package_name>
npm uninstall -g
npm uninstall -g <@scope/package_name>