乐闻世界logo
搜索文章和话题

How to reset the npm registry in global npm config

1个答案

1

When using npm, resetting or changing the global registry is often done to improve the speed of installing dependencies or to switch to a more suitable registry. This can be achieved through the following steps:

1. Check Current Registry: You can first check the current registry using the command line to confirm which registry is in use. Use the following command:

shell
npm config get registry

2. Reset to Default npm Registry: If you want to reset the registry to the default npm registry, use the following command:

shell
npm config set registry https://registry.npmjs.org/

This command sets the global npm registry to the official npm registry.

3. Verify Changes: After changing the registry, you can run npm config get registry again to confirm that the registry has been successfully updated.

For example, if you previously set up the Taobao mirror registry (commonly used by Chinese developers as it is faster than the official registry), you might see the following configuration:

shell
https://registry.npmmirror.com/

After executing the reset command, checking the registry again should display:

shell
https://registry.npmjs.org/

This successfully resets the global npm registry. This operation is useful for resolving dependency installation issues or switching to the optimal registry when developing across different regions.

2024年6月29日 12:07 回复

你的答案