What’s the NRM

NRM, or NPM Registry Manager, is a mirror source management tool for NPM

Why NRM

(https://juejin.cn/post/6844904102967656456) in a previous article talked about how to publish NPM package to NPM server, the company has its own private servers, so it needs to be mirror image source switching back and forth through the following way, operation trival error-prone.

npm config set registry https://registry.npmjs.org/
Copy the code

How do I install NRM

npm install -g nrm
Copy the code

Use NRM to view all current mirror sources

nrm ls
Copy the code

The results are as follows:

  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/
* qunhe ------ http://npm-registry.qunhequnhe.com/
Copy the code

Note: The source marked with * is currently in use

Changing the Mirror Source

// Switch to taobao's mirror source
nrm use taobao
// Switch to the mirror source of CNPM
nrm use cnpm
Copy the code

Adding a Mirror Source

You can add custom mirror sources, especially for private sources within an enterprise, by running the command NRM add < Registry >

, where reigstry is the source name and URL is the source path.

nrm add registry http://npm-registry.qunhequnhe.com/
Copy the code

Deleting a Mirror Source

// reigstry is the source name
nrm del <registry>
Copy the code

Tests the response time of the mirror source

nrm test npm
Copy the code