一、通过命令配置
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
相关推荐
用户059540174463 小时前
把AI对话记忆存储测试从手工改成Playwright+pytest,覆盖率从20%提到96%,回归时间缩短90%kyriewen3 小时前
别再这样写TypeScript了——Code Review中最常见的8个反模式名字还没想好☜3 小时前
Next.js ‘use client‘ 到底加在哪:Server/Client Components 边界与常见报错午安~婉3 小时前
GitHub Token/ GitHub Stats统计显示图异常码云之上4 小时前
AI Agent 工程化总览篇:从 Prompt 到 Harness2501_926978334 小时前
以说明书 DNA 为模板——完整 AGI 的结构图景IT_陈寒4 小时前
Vite静态资源引用这个坑我踩得有点疼程序员黑豆5 小时前
鸿蒙应用开发:AttributeModifier 使用教程codeniu5 小时前
TRAE Work 实战 | 从"有个想法"到线上Demo,我全程只靠对话就完成了妙码生花5 小时前
从 PHP 到 AI + Golang,程序员自救转型手记(五十):增加管理员角色组管理