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
目录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
- Search address: http://npm.taobao.org/
- registry address: http://registry.npm.taobao.org/
cnpmjs Mirror
- Search address: http://cnpmjs.org/
- registry address: http://r.cnpmjs.org/
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 许可协议。转载请注明出处!
相关文章
使用 swagger-typescript-api 在前端项目里生成请求代码
swagger-typescript-api?文档写得像草稿,还得自己摸索。那些花哨的模块化选项除了报错还能干嘛?老老实实生成单文件,配个客户端封装,省得每次折腾。
2025-11-03 · Web前端 · 约 1 分钟
主流 nodejs 包管理器 pnpm vs bun vs npm vs yarn 简单横评
pnpm还真是会玩空间魔术?单项目里它领先优势就这么点?Node.js 20把npm喂肥了,现在谁还敢说npm是废物?这测试结果真是让人摸不着头脑。
2025-08-27 · Web前端 · 约 1 分钟
NextJs 与 Tailwind 入门开发笔记
Next.js?React的脚手架罢了,开箱即用,拒绝精神内耗。Tailwind?Bootstrap的替代品,罢了。实际开发中,pnym坑死人,localStorage问题?小菜一碟。
2024-01-27 · Web前端 · 约 1 分钟
Vue2.x项目整合ExceptionLess监控
前言 一直以来我们都是用Sentry做项目监控,不过前段时间我们的Sentry坏掉了~~(我搞坏的)~~ 但监控又是很有必要的,在sentry修好之前,我想先寻找一个临时的替代方案,同时发现网上关于ExceptionLess的资料少得可怜,ExceptionLess官方的文档也不是很完善,翻了好久文档和源码,于是有了本文…… 关于ExceptionLess 写.NetCore的同学应该不会陌生,这
2022-03-23 · Web前端 · 约 1 分钟
讨论
共 0 条加载评论中…