曦远 (DealiAxy)一份私人的文字刊物

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 许可协议。转载请注明出处!

相关文章

React + TypeScript + Taro前端开发小结

前言 项目到一段落,先来记录一下,本文以前端新手的角度记录React、TypeScript、Taro相关技术的开发体验以及遇到的问题和解决方法。 之前总说要学React(这篇博客:代码使我头疼之React初学习),这次项目需要做H5前端+小程序,我终于能用上React了~ 使用React的开发框架之前就听过京东的Taro,所以就这个了,直接开码。 关于React 不错,感觉比Vue的模板写法自由很

2022-04-22 · Web前端 · 约 1 分钟

讨论

共 0 条

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

加载评论中…