The download speed of front-end npm, yarn, pnpm is too slow, there are several ways to set up the domestic mirror source to make its speed fly

 1. Explain that
the speed of using foreign mirror sources in front-end development is very slow and it is easy to fail to download. Sometimes it takes several attempts to download successfully, which is very troublesome, so you can switch to domestic mirror sources. The following is the commonly used npm, Yarn, pnpm switch domestic image sources (take Taobao as an example).

 2. NPM switch mirror source
1. Check the current mirror source.
```
npm config get registry
```

2. Set as Taobao source
```
npm config set registry https://registry.npm.taobao.org
```

3. Restore the default source
```
npm config set registry https://registry.npmjs.org/
```

4. Temporary use
The above setting is global, and the source that has been set will be automatically read every time in the future. If it is only for one-time use, you can use the following command
```
npm --registry https://registry.npm .taobao.org install XXX (module name)
```

4. Use cnpm
cnpm is a command, use it instead of npm
```
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install XXX(module name)
```

5. Use nrm
```
npm install -g nrm
nrm use taobao
nrm ls # View currently available source commands
```

### 3. Yarn switch mirror source
1. View current mirror source
```
yarn config get registry
```
2. Set as Taobao mirror source
```
yarn config set registry https://registry.npmmirror.com
`` `
3. Switch back to the original mirror source```
yarn
config set registry https://registry.yarnpkg.com
```
### 3. pnpm switch mirror source

1. View the current mirror source
```
pnpm config get registry
```

2. Set as Taobao mirror source
```
pnpm config set registry https://registry.npmmirror.com
```

3. Switch back to the original image source
```
pnpm config set registry https://registry.npmjs.org
```

Guess you like

Origin blog.csdn.net/u012970287/article/details/131100890