myesn

myEsn2E9

hi
github

npm/Yarn: Replace domestic repository mirror source address

Introduction#

npm and yarn change the default download repository center address, you must set it or it will be painfully slow.

Generally, the mirror site provided by the Taobao team is used: https://npmmirror.com.

Automated Source Switching Settings#

It is recommended to use the open-source tool chsrc for automatic settings.

Steps:

  1. Download the executable file for your operating system from the Releases page. I am using Windows, so I downloaded chsrc-x64-windows.exe.
  2. Then open the terminal and execute chsrc-x64-windows.exe list to see the software that supports source switching, etc.
  3. Since we are using nodejs, execute chsrc-x64-windows.exe set nodejs in the terminal, and then wait for it to complete; this process is automatic.

Manual Global Settings#

npm Global Settings#

yarn Global Settings#

Manually Set yarn for a Single Project#

Create a .yarnrc file in the project root directory, then paste the following content into it and save:

Note#

The above configuration will only be used when adding new dependencies, the download addresses of old dependency packages are saved in the lock file and need to be modified manually. For example, the modification method for yarn.lock is as follows:
Replace all instances of https://registry.yarnpkg.com in the yarn.lock file with https://registry.npmmirror.com.

References#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.