npm installation is too stuck and slow

Recently, after I discovered that I was working on a git project at home npm i, I started downloading it very quickly, but then it got stuck and it took about a few minutes to finish downloading. This is intolerable to a coder with obsessive-compulsive disorder.

When in doubt, ask GPT first

GPT also provides several solutions:
1. Change the mirror source: npm's default mirror source may be affected by geographical location, resulting in slow download speeds. You can try to use domestic mirror sources to speed up downloading, such as Taobao mirror (https://npm.taobao.org/) or cnpm (https://github.com/cnpm/cnpm).

npm config set registry https://registry.npm.taobao.org/  //使用淘宝镜像

2. Use yarn: yarn is a package management tool that replaces npm. It uses optimization strategies such as parallel downloading and local caching, so it is faster than npm in some cases. You can try using yarn to manage your packages.

npm install -g yarn

Checking my local settings, I found that I was also using Taobao mirror, so I could only continue, and finally found out

注意: Taobao npm mirror station has switched to a new domain name

New Web site: https://npmmirror.com,

Registry Endpoint:https://registry.npmmirror.com

As the new domain name has been officially launched, the old http://npm.taobao.organd http://registry.npm.taobao.orgdomain names will cease service from 0:00 on May 31, 2022


更换:npm config set registry https://registry.npmmirror.com

查看是否更换成功:npm config get registry

执行安装命令:npm install

Some common settings about mirror sources

npm view the current source:

npm config get registry

npm sets Taobao mirror source:

npm config set registry https://registry.npmmirror.com

Finally, I recommend an npm management tool

nrm to view and switch images

npm install -g nrm
// 查看所有的源
nrm ls

// 增加源地址
nrm add 
nrm add taobao https://registry.npmmirror.com/

// 切换 比如切换到 淘宝源
nrm use tobao

// 删除源地址
nrm del 
nrm del taobao

// 测试所有源的相应时间 看那个更快
nrm test

Do you think it is similar to nvm?

Guess you like

Origin blog.csdn.net/to_prototy/article/details/132487675