0.4.4 • Published 3 months ago

nnrm v0.4.4

Weekly downloads
93
License
MIT
Repository
github
Last release
3 months ago

nnrm

English Docs | 中文文档

npm GitHub code size in bytes node-current npm Libraries.io dependency status for latest release Snyk Vulnerabilities for npm scoped package

nnrm = new nrm

新的 npm 源管理器。

相比 nrm 使用了更小的依赖。

nnrmnrm
install sizeinstall size

由来

安装

# install
npm install -g nnrm
yarn global add nnrm
pnpm add -g nnrm

使用

以下命令是用来切换对应的包管理工具的源。

  • nnrm & nrm: npm
  • nyrm & yrm: yarn(v1-v3)
  • prm: pnpm
nnrm 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

默认源

Features

nnrm 相比 nrm 的改进之处:

  • 支持 yarn(v1-v3) (yarn 与 npm 的 registry 是互相独立的,pnpm 则与 npm 相同)
    • yarn(v3) 的配置字段使用 npmRegistryServer 替代了 registry
  • 极小的依赖
  • 异步地显示源测速结果
  • 彩色的输出结果
  • 每次修改后自动显示 registry 列表,并标记当前 registry

FAQ

为什么要写新的 nrm?

nrm 依赖了已经弃用的 request 和包体较大的 npm,以及其他一些依赖。

所以在没有切换镜像源时,安装 nrm 是一件很慢的事情。

为什么使用 cac?

minimist vs commander vs cac | npm trends

minimist 仅仅 1.3 KB,但它只是一个参数解析工具。

我们需要一个可以自动生成帮助信息的工具。

commandercac 可以做到。

cac(3.6KB) 相比 commander(6.8KB) 更小。并且它的名字取自我喜爱的动漫人物 C.C.

为什么使用 node-fetch?

node-fetch vs axios vs request

node-fetch 大小仅仅 289B!

axios(4.6KB) 很棒,但是 node-fetch 更小。

request(184.8KB) 已经被弃用了,而且它是如此的大。

为什么使用 execa?

execa vs shelljs

execa 大小仅仅 8.4KB。

安装 npm 包来使用 npm.config.set('registry', 'xxx') 的代价是十分昂贵的。

我们只需要执行本地的命令: npm config set registry xxx

Windows 报错?

如果您是 Windows 用户,您可能需要确保你使用 bash 等类 UNIX 通用命令行(而非 CMD)。

参考

赞助者

0.4.4

3 months ago

0.4.3

12 months ago

0.4.2

12 months ago

0.4.0-beta.0

1 year ago

0.4.0-beta.1

1 year ago

0.4.1

1 year ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.2

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.1

2 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago