本文最后更新于 292 天前 ,文中信息可能已经过时。如有问题请在评论区留言。

语法

执行以下命令配置镜像库:(将以下 your_npm_registry_url 替换为你的私有仓库路径或国内镜像源路径)

shell
1
npm config set registry your_npm_registry_url

执行以下命令,返回 your_npm_registry_url,则配置成功:

shell
1
npm config get registry

配置有密码的私有仓库

执行以下命令登录私有仓库:

shell
1
npm login --registry=your_npm_registry_url

按提示输入账号/密码即可。

国内镜像源

腾讯

shell
1
npm config set registry http://mirrors.cloud.tencent.com/npm/

阿里

shell
1
npm config set registry https://registry.npmmirror.com

华为

shell
1
npm config set registry https://mirrors.huaweicloud.com/repository/npm/