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 cnpm
download related packages, the usage is the npm
same as
# 使用国外npm服务器
npm install art-template
# 使用淘宝镜像
cnpm install art-template
If you don’t want to install and cnpm
want to use Taobao’s server to download, you can modify npm
the registry
attributes
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 install
will be downloaded through Taobao’s server by default