Solve the problem of slow download speed of npm

The server where npm stores the package files is abroad, sometimes it will be blocked, and the speed is very slow.

Solution: Use domestic mirror source

For example: Taobao: http://npm.taobao.org/

Install Taobao's cnpm

# 在任意目录执行都可以
# --global 表示安装到全局,而非当前目录,不能省略,否则不管用
npm install --global cnpm

Then you can use to cnpmdownload related packages, the usage is the npmsame as

# 使用国外npm服务器
npm install art-template

# 使用淘宝镜像
cnpm install art-template

If you don’t want to install and cnpmwant to use Taobao’s server to download, you can modify npmthe registryattributes

npm install art-template --registry=http://registry.npm.taobao.org

But it is troublesome to manually add parameters every time, the solution: modify this parameter in the configuration file

npm config set registry https://registry.npm.taobao.org

# 查看npm 配置信息
npm config list

As long as the configuration of the above command is used, the future npm installwill be downloaded through Taobao’s server by default

Guess you like

Origin blog.csdn.net/chen__cheng/article/details/114672748