返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
Web前端

Using Domestic NPM Mirror Sources to Improve Speed

NPM Introduction npm (full name Node Package Manager, i.e. “node package manager”) is Node.js’s default package management system written in JavaScript. npm can manage the modules required by local projects and automatically maintain dependencies, and can also manage globally installed JavaScript tools. However, because npm’s registry is located abroad, using it in China often results in speeds as low as 10kb/s, or even complete download failures, so it is necessary to use domestic mirror sources instead of the official source. Domestic sources Taobao np

曦远 (DealiAxy)约 6 分钟
目录11 个章节

NPM Introduction

npm (full name Node Package Manager, i.e. “node package manager”) is Node.js’s default package management system written in JavaScript. npm can manage the modules required by local projects and automatically maintain dependencies, and can also manage globally installed JavaScript tools.

However, because npm’s registry is located abroad, using it in China often results in speeds as low as 10kb/s, or even complete download failures, so it is necessary to use domestic mirror sources instead of the official source.

Domestic Sources

Taobao npm Mirror

cnpmjs Mirror

npm mirror

Updated 2022-2-25 10:30:51

The Taobao mirror is about to stop being maintained, so now switch to this one, which is also sponsored by Alibaba Cloud

Configuration Methods

There are many ways to configure npm’s registry address. Below are several commonly used methods for different situations. Taking the Taobao npm mirror as an example:

Temporary Configuration

npm --registry https://registry.npmmirror.com install express

Save Configuration

This is recommended, since configuring it every time you use npm is too much of a hassle.

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

After configuration, you can verify whether it succeeded with the following methods

npm config get registry

or

npm info express

Use via cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com

Test usage

cnpm info express

Proxy Configuration

Updated 2022-2-15 21:38:49

Sometimes you need to use some third-party repositories, such as font-awesome’s, which cannot use domestic mirrors, so in that case you can only use a proxy

npm config set proxy=http://host:port
npm config set https-proxy=http://host:port

Remove Proxy

npm config delete proxy
npm config delete https-proxy

_EOF_

Using Domestic NPM Mirror Sources to Improve Speed

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…