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 许可协议。转载请注明出处!
相关文章
魔改editormd组件,优化ToC渲染效果
前言 我的StarBlog博客目前使用 editor.md 组件在前端渲染markdown文章,但这个组件自动生成的ToC(内容目录)不是很美观,我之前魔改过一个树形组件 BootStrap-TreeView,所以就想要用这个树形组件来展示ToC。 原本的效果是这样的 image-20221020112752560 我魔改完的效果 image-20221020112914518 先分析一波 首先看
2022-10-20 · Web前端 · 约 1 分钟
返璞归真!使用 Alpine.js 开发交互式 web 应用,抛弃 node_modules 和 webpack 吧!
前端框架层出不穷,项目越做越大,alpine.js 和 htmx 这种库是反其道而行,可以用最简单的方法来开发现代化的 web 应用。
2024-11-21 · Web前端 · 约 1 分钟
在HTML中引入React和JSX
Vue 可以非常方便地与 Pure HTML 结合,代替 jQuery 的功能,有一次遇到类似的场景时,我就想 React 能不能也以这种方式接入 HTML 网页,从而提高开发效率。 结果当然是可以的,只不过在 HTML 里直接 JSX 似乎会降低一些性能… 凑合用吧
2023-07-16 · Web前端 · 约 1 分钟
React + TypeScript + Taro前端开发小结
前言 项目到一段落,先来记录一下,本文以前端新手的角度记录React、TypeScript、Taro相关技术的开发体验以及遇到的问题和解决方法。 之前总说要学React(这篇博客:代码使我头疼之React初学习),这次项目需要做H5前端+小程序,我终于能用上React了~ 使用React的开发框架之前就听过京东的Taro,所以就这个了,直接开码。 关于React 不错,感觉比Vue的模板写法自由很
2022-04-22 · Web前端 · 约 1 分钟
讨论
共 0 条加载评论中…