一、通过命令配置
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
相关推荐
ZXT2 分钟前
promise & async await总结Jerry说前后端2 分钟前
RecyclerView 性能优化:从原理到实践的深度优化方案画个太阳作晴天10 分钟前
A12预装app77238936 分钟前
解决 Microsoft Edge 显示“由你的组织管理”问题烛阴1 小时前
前端必会:如何创建一个可随时取消的定时器JarvanMo1 小时前
Swift 应用在安卓系统上会怎么样?LinXunFeng1 小时前
Flutter - 详情页 TabBar 与模块联动?秒了!萌萌哒草头将军2 小时前
Oxc 最新 Transformer Alpha 功能速览! 🚀🚀🚀Justinc.2 小时前
HTML5新增属性1024小神3 小时前
nextjs项目build导出静态文件