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 许可协议。转载请注明出处!
相关文章
在Next.js中集成swagger文档
Next.js 本来就不能直接用 Swagger,非要用还得自己折腾 API Routes?自动生成工具?手动写 Spec?这简直是在侮辱开发者。手动注释?这操作简直是在挑战耐心极限。
2025-09-01 · Web前端 · 约 1 分钟
在TypeScript项目中搭配Axios封装后端接口调用
封装axios?TypeScript下不过是加些类型声明,真当创新了。拦截器自动加token和401跳转,标准操作而已。统一返回值?又是后端那套,麻烦。
2024-01-24 · Web前端 · 约 1 分钟
前端邪修:不用Vite也不用Webpack,把React拖回HTML时代的反工程化实践
反工程化React实践?直接HTML引入React写界面?这操作够“邪修”吧。工具链?HMR?不需要,手动加载依赖,浏览器缓存自己控。简单交互页面何必引入整套工程体系?这取舍,够“高冷”。
2025-12-30 · Web前端 · 约 1 分钟
使用 swagger-typescript-api 在前端项目里生成请求代码
swagger-typescript-api?文档写得像草稿,还得自己摸索。那些花哨的模块化选项除了报错还能干嘛?老老实实生成单文件,配个客户端封装,省得每次折腾。
2025-11-03 · Web前端 · 约 1 分钟
讨论
共 0 条加载评论中…