npm 的使用总结
一、新域名
- 官方地址 : https://npmmirror.com
- 镜像地址 : https://registry.npmmirror.com
- 老域名:http://npm.taobao.org 和 http://registry.npm.taobao.org 将在 2022.06.30 号正式下线和停止 DNS 解析
原来的 registry.npm.taobao.org 已替换为 registry.npmmirror.com ,当点击 registry.npm.taobao.org 会默认跳转到 registry.npmmirror.com
二、npm镜像源
1. 设置镜像源:--registry
临时使用镜像;registry
持久配置镜像。
npm config set registry https://registry.npm.taobao.org
2. 查看当前使用的镜像地址:
npm config get registry
3.还原为国外地址:
npm config set registry https://registry.npmjs.org
4. 使用专门为加速 npm 设计的工具:例如 cnpm 和 nrm
npm install cnpm -g
5、清空缓存
npm cache clean --force
执行cnpm install lodash
,会在node_modules
文件夹下生成两个文件夹:_lodash@4.17.11@lodash
和lodash
cnpm
安装的2个模块,两者存在引用关系
实测发现,尽管使用npm
改成淘宝仓库,发现安装速度还是远远比cnpm
慢(当模块比较多的时候)。应该和cnpm
安装的文件结构有关系。
参考地址:https://blog.csdn.net/sunhuaqiang1/article/details/118191084
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义