UNPKG

4.71 kBMarkdownView Raw
1# nnrm
2
3English Docs | [中文文档](./README.zh-CN.md)
4
5[![npm](https://img.shields.io/npm/v/nnrm)](https://www.npmjs.com/package/nnrm)
6![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/yunyoujun/nnrm)
7[![node-current](https://img.shields.io/node/v/nnrm)](https://nodejs.dev/)
8![npm](https://img.shields.io/npm/dt/nnrm)
9![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/nnrm)
10![Snyk Vulnerabilities for npm scoped package](https://img.shields.io/snyk/vulnerabilities/npm/nnrm)
11
12> nnrm = new nrm
13
14New npm registry manager.
15
16Use smaller dependencies than [nrm](https://github.com/Pana/nrm).
17
18> [由来](https://www.yunyoujun.cn/posts/nnrm-new-nrm/)
19
20## Install
21
22```sh
23# install
24npm install -g nnrm
25yarn global add nnrm
26pnpm add -g nnrm
27```
28
29## Usage
30
31These commands are used to toggle the corresponding registry.
32
33- `nnrm` & `nrm`: npm
34- `nyrm` & `yrm`: yarn
35- `prm`: pnpm
36
37```sh
38nnrm ls
39# nrm ls
40# yrm ls
41# prm ls
42
43nnrm use taobao
44# nrm use taobao
45# yrm use taobao
46# prm use taobao
47
48# set `.npmrc` for local
49nrm use taobao -l
50
51nnrm test
52# nrm test
53# yrm test
54# prm test
55```
56
57- `nnrm -h`: show help message
58
59```bash
60Usage:
61 $ nrm <command> [options]
62
63Commands:
64 ls List all the registries
65 use [registry] Change registry
66 test Show response time for all registries
67 add <registry> <url> [home] Add a custom registry
68 remove <registry> Remove a custom registry
69
70Options:
71 -h, --help Display this message
72 -v, --version Display version number
73```
74
75```bash
76Usage:
77 $ nrm use [registry]
78
79Options:
80 -l, --local set '.npmrc' for local
81```
82
83### Add/Remove custom registry
84
85```bash
86nnrm add example https://xxx.com
87```
88
89```bash
90nnrm remove example
91```
92
93It will be recorded in your `~/.nnrm/registries.json`.
94
95### Default Registires
96
97- npm -------- <https://registry.npmjs.org/>
98- yarn ------- <https://registry.yarnpkg.com/>
99- taobao ----- <https://registry.npmmirror.com/> (taobao redirect `npm.taobao.org` to `npmmirror.com`)
100- tencent ---- <https://mirrors.cloud.tencent.com/npm/>
101- npmMirror -- <https://skimdb.npmjs.com/registry/>
102- github ----- <https://npm.pkg.github.com/>
103
104## Features
105
106- Support `npm`/`yarn`/`pnpm` (the registry of `yarn` and `npm/pnpm` is independent of each other)
107- Smaller Dependencies
108 - Use `node-fetch` instead of `request` for speed test
109 - Use `execa` instead of `npm`
110 - Use `cac` instead of `commander`
111- Asynchronously display source speed test results
112- Colorful console info
113- Automatically display the registry list after each modification, and mark the current registry
114
115## FAQ
116
117### Why new nrm?
118
119nrm relies on the deprecated `request` with a larger package body, the `npm` package, and some other npm dependencies.
120
121So installing nrm is also a very slow thing.
122
123### Why cac?
124
125> [minimist vs commander vs cac | npm trends](https://www.npmtrends.com/minimist-vs-commander-vs-cac)
126
127[minimist](https://github.com/substack/minimist) is only 1.3 KB, but it is just a parameter parsing tool.
128
129We need a tool that can automatically generate help information.
130
131[commander](https://github.com/tj/commander.js) and [cac](https://github.com/cacjs/cac) can do it.
132
133cac(3.6KB) is smaller than commander(6.8KB). ~~And i love C.C.~~
134
135### Why node-fetch?
136
137> [node-fetch vs axios vs request](https://www.npmtrends.com/node-fetch-vs-axios-vs-request)
138
139[node-fetch](https://github.com/node-fetch/node-fetch) is only 289B!
140
141[axios](https://github.com/axios/axios)(4.6KB) is good, but node-fetch is smaller.
142
143[request](https://github.com/request/request)(184.8KB) has been deprecated and it is so big.
144
145### Why [execa](https://github.com/sindresorhus/execa)?
146
147> [execa vs shelljs](https://www.npmtrends.com/execa-vs-shelljs)
148
149[execa](https://github.com/sindresorhus/execa) is only 8.4KB.
150
151Install package [npm](https://www.npmjs.com/package/npm) to use `npm.config.set('registry', 'xxx')` is expensive.
152
153We just need use local command: `npm config set registry xxx`.
154
155### Error when use Windows?
156
157If you are a Windows user, you may want to make sure that you use a generic command line like `bash` instead of `CMD`.
158
159### `nrm` conflicts with other commands
160
161nrm(command) is a command of [nrm(package)](https://github.com/Pana/nrm).
162You should uninstall `nrm(package)` to use `nrm(command)` with `nnrm(package)`. Or you can use `nnrm(command)`.
163
164> nrm(command) may conflict with [nrm](https://github.com/Pana/nrm) or [ni](https://github.com/antfu/ni). You can uninstall them or just use command `nnrm` without uninstalling them.
165
166## Ref
167
168- [npm-config | npm Docs](https://docs.npmjs.com/cli/v7/commands/npm-config)