时间:2023-03-11 11:00:07 | 栏目:JavaScript代码 | 点击:次
npm i -g cnpm --registry=https://registry.npm.taobao.org
cnpm i -g vue vue-cli
E:\我的项目\2018-08>cnpm config ls ; cli configs disturl = "https://npm.taobao.org/mirrors/node" metrics-registry = "https://registry.npm.taobao.org/" registry = "https://registry.npm.taobao.org/" scope = "" user-agent = "npm/6.3.0 node/v8.11.3 win32 x64" userconfig = "C:\\Users\\Administrator\\.cnpmrc" ; node bin location = D:\Program Files\nodejs\node.exe ; cwd = E:\我的项目\2018-08 ; HOME = C:\Users\Administrator ; "npm config ls -l" to show all defaults. E:\我的项目\2018-08>
会发现里面的registry变成了淘宝的镜像(仓库):https://registry.npm.taobao.org/
【本文里面的“镜像”等同于“仓库”,下同】
E:\我的项目\2018-08>npm config ls ; cli configs metrics-registry = "https://registry.npmjs.org/" scope = "" user-agent = "npm/5.6.0 node/v8.11.3 win32 x64" ; userconfig C:\Users\Administrator\.npmrc cache = "D:\\Program Files\\nodejs\\node_cache" prefix = "D:\\Program Files\\nodejs\\node_global" ; builtin config undefined ; node bin location = D:\Program Files\nodejs\node.exe ; cwd = E:\我的项目\2018-08 ; HOME = C:\Users\Administrator ; "npm config ls -l" to show all defaults. E:\我的项目\2018-08>
会发现里面的registry是npm原始的镜像:https://registry.npmjs.org/
npm i -g express --registry https://registry.npm.taobao.org
npm config set registry https://registry.npm.taobao.org npm i -g express
注意,不推荐这样子,因为把npm的镜像完全设为了淘宝的镜像,万一我们有些依赖包只有npm原始镜像里面才有,而淘宝里面没有,那就悲剧了。所以分开npm和cnpm是最好的。
npm config ls cnpm config ls
npm cofig set cache "D:\Program Files\nodejs\node_cache" npm cofig set prefix "D:\Program Files\nodejs\node_global" cnpm cofig set cache "D:\Program Files\nodejs\node_cache" cnpm cofig set prefix "D:\Program Files\nodejs\node_global"
E:\我的项目\2018-08>cnpm config ls ; cli configs disturl = "https://npm.taobao.org/mirrors/node" metrics-registry = "https://registry.npm.taobao.org/" registry = "https://registry.npm.taobao.org/" scope = "" user-agent = "npm/6.3.0 node/v8.11.3 win32 x64" userconfig = "C:\\Users\\Administrator\\.cnpmrc" ; userconfig C:\Users\Administrator\.cnpmrc cache = "D:\\Program Files\\nodejs\\node_cache" prefix = "D:\\Program Files\\nodejs\\node_global" ; node bin location = D:\Program Files\nodejs\node.exe ; cwd = E:\我的项目\2018-08 ; HOME = C:\Users\Administrator ; "npm config ls -l" to show all defaults. E:\我的项目\2018-08>npm config ls ; cli configs metrics-registry = "https://registry.npmjs.org/" scope = "" user-agent = "npm/5.6.0 node/v8.11.3 win32 x64" ; userconfig C:\Users\Administrator\.npmrc cache = "D:\\Program Files\\nodejs\\node_cache" prefix = "D:\\Program Files\\nodejs\\node_global" ; builtin config undefined ; node bin location = D:\Program Files\nodejs\node.exe ; cwd = E:\我的项目\2018-08 ; HOME = C:\Users\Administrator ; "npm config ls -l" to show all defaults. E:\我的项目\2018-08>