①git
镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在):github
1.经过config命令express
npm config set registry https://registry.npm.taobao.org npm info underscore (若是上面配置正确这个命令会有字符串response)
2.命令行指定npm
npm --registry https://registry.npm.taobao.org info underscore
3.编辑 ~/.npmrc
加入下面内容spa
registry = https://registry.npm.taobao.org
搜索镜像: https://npm.taobao.org命令行
创建或使用镜像,参考: https://github.com/cnpm/cnpmjs.orgcode
有不少方法来配置npm
的registry地址,下面根据不一样情境列出几种比较经常使用的方法。以淘宝npm
镜像举例:字符串
npm --registry https://registry.npm.taobao.org install express
npm config set registry https://registry.npm.taobao.org // 配置后可经过下面方式来验证是否成功 npm config get registry // 或 npm info express
cnpm
使用npm install -g cnpm --registry=https://registry.npm.taobao.org // 使用 cnpm install express
yarn设置淘宝镜像underscore
$ yarn config set registry https://registry.npm.taobao.org yarn config v1.6.0 success Set "registry" to "https://registry.npm.taobao.org". Done in 0.04s.