The NRM registry Manager (NRM) is an NPM image source management tool. You can use it to quickly switch between NPM sources.

As a front-end developer, you must use NPM to install third party relies on package, but as a result of NPM default download storage address is https://registry.npmjs.org/, belong to the foreign website, so we can be very slow to download. So Taobao also created a mirror of NPM (see here).

For example, if we switch to taobao mirror source, we can complete the switch through the following command:

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

But the command is too long to remember, so let’s use NRM to switch quickly.

Using the CNPM command instead of NPM to install dependencies is not recommended.

NRM installation and use

  1. Global installation
$ npm i -g nrm
Copy the code
  1. Check the version
$ nrm -V
Copy the code
  1. View all Sources

* indicates the source currently in use.

$ nrm ls

* 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/
Copy the code

Or run the NRM current command to view the name of the current source.

  1. Switch the source

Where

is the name listed in the command above.

Compared to the above command, is not easy to remember.

$ nrm use <registry>
#For example, NRM use Taobao
Copy the code

Note that after switching sources, we still use NPM I

to install dependencies.

  1. Add the source

For private sources customized within the enterprise, < Registry > represents the source name and < URL > represents the source address.

$ nrm add <registry> <url>
Copy the code
  1. Delete the source
$ nrm del <registry>
Copy the code
  1. Test the response time of the source
$ nrm test <registry>
Copy the code

reference

  • NPM registry manager