当前位置:网站首页>nrm 使用详解
nrm 使用详解
2022-08-10 07:41:00 【1024小神】

一、什么是 nrm?
nrm(NPM registry manager)是 NPM 的镜像源管理工具,使用它可以快速切换 npm 命令镜像源。
作为前端开发,你一定使用过 npm 来安装第三方依赖包,但由于 NPM 默认的下载仓储地址是 https://registry.npmjs.org/,属于外国的网站,所以我们下载的时候可能会非常的慢。所以淘宝也做了一个 NPM 的镜像网站(看这里)。
比如我们切换成淘宝镜像源,我们可以通过以下命令完成切换:
$ npm config set registry https://registry.npmmirror.com/
# 或者直接在 npm 配置文件修改
$ npm config edit
但是这命令忒长,不好记,所以我们用 nrm 来快速切换吧。另外,个人不推荐使用 cnpm 命令来代替 npm 来安装依赖,请看文章:为什么不推荐使用 cnpm?
「重要通知」原淘宝 npm 域名即将停止解析,请切换至新域名 npmmirror.com,
http://npm.taobao.org和http://registry.npm.taobao.org将在 2022.06.30 号正式下线和停止 DNS 解析。
二、安装与使用
- 全局安装
$ npm i -g nrm
- 查看版本
$ nrm -V
- 查看所有源
其中 * 号表示当前使用的源。
$ nrm ls
* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
taobao ----- https://registry.npmmirror.com/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/
或者通过 nrm current 命令查看当前源的名称。
- 切换源
其中 <registry> 就是上面命令所列出来的名称。
相比上面的命令,是不是方便好记多了
$ nrm use <registry>
# 例如 nrm use taobao
注意切换源之后,我们安装依赖仍使用
npm i <name>的方式来进行安装。
- 添加源
适用于企业内部定制的私有源,<registry> 表示源名称,<url> 表示源地址。
$ nrm add <registry> <url>
- 删除源
$ nrm del <registry>
- 测试源的响应时间
$ nrm test <registry>
三、其他
既然 nrm 是 npm 的镜像源管理工具,自然不会影响到 yarn 的配置。若要修改 yarn 镜像源配置,可以通过以下方式:
# 获取当前源
$ yarn config get registry
# 配置源,<registry address> 为源地址
$ yarn config set registry <registry address>
常用的镜像源有:
npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
taobao ----- https://registry.npmmirror.com/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/
好消息,另外一个工具
yrm,可以同时修改npm和yarn的镜像源,详见:一个可同时切换 npm 和 yarn 镜像源的工具。
边栏推荐
- A few lines of code can crash the system;
- Uni-app开发微信小程序使用本地图片做背景图
- 颜色选择器的使用
- ATH10 sensor reads temperature and humidity
- 每日一题,数组字符串的匹配问题
- DGIOT支持工业设备租赁以及远程管控
- Introduction to C integer data storage
- Introduction to the delta method
- IDLE development wordCount program (5)
- 【Event Preview on August 9】Prometheus Summit
猜你喜欢

A few lines of code can crash the system;

英国国家卫生服务遭受攻击,系统出现大面积故障

ABAP Data Types 和XSD Type 映射关系以及XSD Type属性
![Chapter 11 Database Design Specifications [2. Index and Tuning] [MySQL Advanced]](/img/a5/88699cf7b7fc0ca721977dc07b0602.png)
Chapter 11 Database Design Specifications [2. Index and Tuning] [MySQL Advanced]

【MySQL】SQL语句

金融证券 初级 招股书 要求 黑话1刷数 黑话2底稿 黑话3董监高

High quality WordPress download station 5 play theme template

【NeRF】原始论文解读

Relaxation class: the boss will martial arts, who also can not hold up against!The charm of six sigma training

BUUCTF Notes (web)
随机推荐
BUUCTF Notes (web)
initramfs与initrd的区别
Basic use of Log4j2
第2章 变量和基本类型读书笔记
Rust学习:6.1_复合类型之切片
30条实用MySQL优化法则
QT下载清华源配置
Nude speech - lying flat - brushing questions - big factory (several tips for Android interviews)
预测股票涨跌看什么指标,如何预测明天股票走势
PLSQL学习第一天
Complex AB experiment
Fiddler(八) - 抓取手机APP的流量-插件Fiddler Orchestra Beta安装&配置
Chapter 12 Other Database Tuning Strategies [2. Index and Tuning] [MySQL Advanced]
ATH10 sensor reads temperature and humidity
IDLE开发wordCount程序(第五弹)
CV-人脸识别-2018:ArcFace
深入理解LTE网络的CDRX
uni 小程序腾讯地图polygon背景透明度
Introduction to C integer data storage
初使jest 单元测试