Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

An NPM image source management tool was introduced to quickly switch between NPM sources, that is, NRM.

See article: NRM usage details.

The original command for setting the NPM or YARN source is as follows:

# use npm
$ npm config set registry <registry-url>

# use yarn
$ yarn config set registry <registry-url>
Copy the code

With NRM you can quickly switch sources:

# nrm use taobao
$ nrm use <registry>
Copy the code

NRM can’t change yarn’s image source.

A YARN Registry Manager (YRM) tool was recently discovered to synchronize NPM and YARN image sources. It is also a Fork of THE NRM.

# install
$ npm i yrm -g

# switch registry
$ yrm use <registry>

#.
Copy the code

The usage method is consistent with NRM, so I won’t go into more details. If you are not familiar with NRM, take a look at the previous article. You can also run -h to view all commands.

frankie@iMac ~ % 🐶 yrm -h

Usage: yrm [options] [command]

Options:
  -V, --version                output the version number
  -h, --help                   output usage information

Commands:
  ls                           List all the registries
  current                      Show current registry name
  use <registry>               Change registry to registry
  add <registry> <url> [home]  Add one custom registry
  del <registry>               Delete one custom registry
  home <registry> [browser]    Open the homepage of registry with optional browser
  test [registry]              Show response time for specific or all registries
  help                         Print this help
Copy the code

You cannot use publish when using other non-default registries. I usually publish NPM packages directly using the NPM public command.

The effect is as follows:

frankie@iMac ~ % 🐶 yrm use taobao

   YARN Registry has been set to: https://registry.npm.taobao.org/

   NPM Registry has been set to: https://registry.npm.taobao.org/
Copy the code

Refenerces

  • nrm – Github
  • yrm – Github
  • Details on NRM usage