English Docs | 中文文档
nnrm = new nrm
新的 npm 源管理器。
相比 nrm 使用了更小的依赖。
| nnrm | nrm |
|---|---|
# install
npm install -g nnrm
yarn global add nnrm
pnpm add -g nnrm
以下命令是用来切换对应的包管理工具的源。
nnrm & nrm: npmnyrm & yrm: yarn(v1-v3)prm: pnpmnnrm ls
# nrm ls
# yrm ls
# prm ls
nnrm use taobao
# nrm use taobao
# yrm use taobao
# prm use taobao
# 设置本地的 `.npmrc`
nrm use taobao -l
nnrm test
# nrm test
# yrm test
# prm test
nnrm -h: 显示帮助信息Usage:
$ nrm <command> [options]
Commands:
ls List all the registries
use [registry] Change registry
test Show response time for all registries
add <registry> <url> [home] Add a custom registry
remove <registry> Remove a custom registry
Options:
-h, --help Display this message
-v, --version Display version number
Usage:
$ nrm use [registry]
Options:
-l, --local set '.npmrc' for local
# 添加自定义源
nnrm add example https://xxx.com
# 移除自定义源
nrm remove example
它将会被记录在你的 ~/.nnrm/registries.json。
npm.taobao.org 重定向至 npmmirror.com)nnrm 相比 nrm 的改进之处:
pnpm 则与 npm 相同)yarn(v3) 的配置字段使用 npmRegistryServer 替代了 registrynode-fetch (289B) 替代 request (184.8KB) 进行测速 node-fetch vs axios vs request | npmtrendsexeca (8.4KB) 替代 npm (455.4KB) 通过终端而非 node API 实现切换 execa vs npm | npmtrendscac (3.6KB) 替代 commander (6.8KB) 实现简单的终端 cac vs commander | npmtrendsnrm 依赖了已经弃用的 request 和包体较大的 npm,以及其他一些依赖。
所以在没有切换镜像源时,安装 nrm 是一件很慢的事情。
minimist 仅仅 1.3 KB,但它只是一个参数解析工具。
我们需要一个可以自动生成帮助信息的工具。
cac(3.6KB) 相比 commander(6.8KB) 更小。~~并且它的名字取自我喜爱的动漫人物 C.C.~~
node-fetch 大小仅仅 289B!
axios(4.6KB) 很棒,但是 node-fetch 更小。
request(184.8KB) 已经被弃用了,而且它是如此的大。
execa 大小仅仅 8.4KB。
安装 npm 包来使用 npm.config.set('registry', 'xxx') 的代价是十分昂贵的。
我们只需要执行本地的命令: npm config set registry xxx。
如果您是 Windows 用户,您可能需要确保你使用 bash 等类 UNIX 通用命令行(而非 CMD)。