Skip to content

Accelerating Access to npm and Yarn in China by Changing the Source

Background

By default, npm and Yarn use overseas source addresses, resulting in slow access in China.
You can check the current mirror source being used with the following command:

yarn config get registry

Solution

Utilize the cgr software to quickly switch between mirror sources for npm and Yarn.

Installing cgr

npm install -g cgr

Listing currently available mirror sources

cgr ls

Selecting a mirror source to switch to (e.g., Taobao)

cgr use taobao

Testing access speed

cgr test taobao

References and Acknowledgments

Original: https://wiki-power.com/ This post is protected by CC BY-NC-SA 4.0 agreement, should be reproduced with attribution.

This post is translated using ChatGPT, please feedback if any omissions.