NPM镜像源查看和切换

1、镜像源链接切换

//查看镜像源使用状态:
npm get registry
//全局切换镜像源:
npm config set registry http://registry.npm.taobao.org
//全局切换官方镜像源
npm config set registry http://www.npmjs.org

 

2、nrm 管理镜像源

nrm(npm registry manager )是npm的镜像源管理工具,因为上面的代码修改比较麻烦,还得记忆输入网址,这个nrm就比较方便切换镜像源了。

下载 并全局安装nrm:

npm install  nrm -g
npm install -g nrm
//-g表示全局安装

查看可切换的镜像源:  (*表示正在使用的镜像源)       

//显示当前可使用的镜像源列表
nrm ls

 

 

* npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/

3、切换镜像源

切换为淘宝镜像源:

nrm use taobao

 

 

nrm ls报错

 

 【执行有错的,不一一模一样,但是都是这个原因导致的】

则找到第四行找到`cli.js`17行,注释掉,

//注释下列行
const
NRMRC = path.join(process.env.HOME, '.nrmrc'); //替换为 const NRMRC = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.nrmrc');

 

posted @ 2021-09-02 15:48  无风何其浪  阅读(7649)  评论(0编辑  收藏  举报