编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

npm查看各个仓库地址,选择性使用

wxchong 2024-08-27 23:01:51 开源技术 12 ℃ 0 评论

npm包有很多的镜像源,有的源有的时候访问失败,有的源可能没有最新的包等等,所以有时需要切换npm的源,nrm包就是解决快速切换问题的。

nrm可以帮助您在不同的npm源地址之间轻松快速地切换。

安装

要用nrm,要先安装,操作步骤如下:

npm install -g nrm

列出可选择的源

下载完之后,可以查看各个仓库地址,执行以下命令

nrm ls

在我机器上效果:

virhuiai@virhuiaideMacBook-Pro ~ % nrm ls               

  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/

前面带 * 号的表示正在使用的源

切换使用的源

根据自己的需要,选择对应的仓库,具体命令如下所示:

nrm use npm

添加一个源

nrm add 源名 路径 源的主页(可不写)

删除一个源

nrm del 源名

测试源速度

nrm test 源名

不使用nrm的情况

查看当前使用的源

npm config get registry

设置当前使用的源

npm config set registry 路径

安装包使用特定源

全部使用特定源安装:

npm install --registry=路径

安装一个包使用特定源:

npm i 包名 --registry=路径

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表