一、通过命令配置
1、设置淘宝镜像源
npm config set registry https://registry.npm.taobao.org/
2、设置官方镜像源
npm config set registry https://registry.npmjs.org
3、查看镜像使用状态:
npm config get registry
如果返回https://registry.npm.taobao.org/,说明配置的是淘宝镜像。
如果返回https://registry.npmjs.org/,说明配置的是淘宝镜像。二、通过使用cnpm安装
1、安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
解决安装卡顿或无法安装:
注册模块镜像
npm set registry https://registry.npm.taobao.org
// node-gyp 编译依赖的 node 源码镜像
npm set disturl https://npm.taobao.org/dist
// 清空缓存
npm cache clean --force
// 安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
2、使用cnpm
cnpm install xxx
npm使用国内淘宝镜像的方法(两种)
菜鸡程序员1452023-08-15 22:18
相关推荐
IT_陈寒11 小时前
Redis那个过期删除策略,差点让我线上崩了jianqiang.xue11 小时前
Espressif-IDE进入维护模式:乐鑫把ESP32开发的宝押给VS Code特创数字科技11 小时前
纯本地离线运行的文档脱敏工具(技术分享)心之语歌12 小时前
uni-app uts原生插件开发:uts 与 Kotlin 交互踩坑实录(附解决方案)再吃一根胡萝卜12 小时前
DSH 插件数据链路:Host 管数据,Client 只管画feixing_fx12 小时前
CSS 变量(Custom Properties):构建可扩展的主题切换系统十有八七13 小时前
手搓 Agent(一):先有大脑——大模型只会做一件事锋行天下13 小时前
「踩坑实录」给 LangGraph Agent 接两个 FastMCP,我被 langchain 偷偷改了工具名跳跳的小星星14 小时前
自研组件】Vue2 + ElementUI 通用列表页封装 wkjp-list-page,一套配置搞定搜索、动态表格、分页、增删改tryCbest14 小时前
Vue3—— 第 18 篇:Vue 2 到 Vue 3 迁移指南——升级避坑全记录