myesn

myEsn2E9

hi
github

npm/Yarn: Replace the mirror address of the domestic repository

Introduction#

npm and yarn change the default download repository center address. Be sure to set it, otherwise it will be painfully slow.

Usually, the mirror provided by the Taobao team is used, which is https://npmmirror.com.

Global Settings#

npm Global Settings#

npm config set registry https://registry.npmmirror.com
npm config set disturl https://npmmirror.com/mirrors/node

# Set the following according to your own situation
npm config set electron_mirror https://registry.npmmirror.com/electron/
npm config set sass_binary_site https://registry.npmmirror.com/node-sass/

yarn Global Settings#

yarn config set registry https://registry.npmmirror.com -g
yarn config set disturl https://npmmirror.com/mirrors/node -g

# Set the following according to your own situation
yarn config set electron_mirror https://registry.npmmirror.com/electron/ -g
yarn config set sass_binary_site https://registry.npmmirror.com/node-sass/ -g

Setting for Individual Yarn Projects#

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

registry https://registry.npmmirror.com
disturl https://npmmirror.com/mirrors/node

# Set the following according to your own situation
electron_mirror https://registry.npmmirror.com/electron/
sass_binary_site https://registry.npmmirror.com/node-sass/

Note#

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

Reference#

https://www.cnblogs.com/myesn/p/14994938.html
https://stackoverflow.com/questions/70590169/install-package-from-private-registry-using-yarn-in-docker
https://www.cnblogs.com/fmixue/p/16375938.html

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