NPM
配置镜像仓库
- 查看默认仓库地址
npm config get registry
# 输出为:https://registry.npmjs.org/
- 修改默认仓库地址
# 设置为私服地址http://nexus.tangyuewei.com/repository/npm-public/
npm config set registry http://nexus.tangyuewei.com/repository/npm-public/
# 设置为淘宝镜像地址
npm config set registry https://registry.npm.taobao.org
修改客户端配置(私服需要配置)
这里需要在私服创建认证账号,及角色,本文就略过了。
自己的私服,需要配置NPM
客户端信息,修改 C:\Users\用户名\.npmrc
registry=http://nexus.tangyuewei.com/repository/npm-public/
email=472680811@qq.com
always-auth=true
_auth="ZGVwbG95ZXI6ZGVwbG95ZXI="
注意: _auth是
username:password
的base64
值,可以通过Linux
命令echo -n 'username:password' | openssl base64
生成。
比如我们的账号密码都是deployer
则生成命令为:
echo -n 'deployer:deployer' | openssl base64
检验配置
npm config get registry
# 输出为:https://registry.npm.taobao.org
# 私服则输出:http://nexus.tangyuewei.com/repository/npm-public/
到此就可以享受快速安装啦,国内淘宝镜像仓库如果有些下载不到,可以继续改回默认的地址
npm config set registry https://registry.npmjs.org/
安装,安装完成后在改回淘宝加速地址就好了
YARN
配置镜像仓库
- 查看默认仓库地址
yarn config get registry
# 输出为:https://registry.yarnpkg.com
- 修改默认仓库地址
# 设置为淘宝地址
yarn config set registry https://registry.npm.taobao.org
yarn config set disturl https://npm.taobao.org/dist