npm使用国内淘宝镜像的方法(两种)

一、通过命令配置

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

相关推荐
Kagol1 小时前
🎉OpenTiny NEXT-SDK 重磅发布:四步把你的前端应用变成智能应用!
前端·开源·agent
GIS之路2 小时前
ArcGIS Pro 中的 notebook 初识
前端
JavaGuide2 小时前
7 道 RAG 基础概念知识点/面试题总结
前端·后端
ssshooter2 小时前
看完就懂 useSyncExternalStore
前端·javascript·react.js
格砸3 小时前
从入门到辞职|从ChatGPT到OpenClaw,跟上智能时代的进化
前端·人工智能·后端
Live000004 小时前
在鸿蒙中使用 Repeat 渲染嵌套列表,修改内层列表的一个元素,页面不会更新
前端·javascript·react native
柳杉4 小时前
使用Ai从零开发智慧水利态势感知大屏(开源)
前端·javascript·数据可视化
兆子龙4 小时前
从高阶函数到 Hooks:React 如何减轻开发者的心智负担(含 Demo + ahooks 推荐)
前端
狗胜4 小时前
测试文章 - API抓取
前端