一、通过命令配置
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
相关推荐
yddddddy6 小时前
css的基本知识昔人'6 小时前
css `lh`单位Nan_Shu_6148 小时前
Web前端面试题(2)知识分享小能手8 小时前
React学习教程,从入门到精通,React 组件核心语法知识点详解(类组件体系)(19)蚂蚁RichLab前端团队9 小时前
🚀🚀🚀 RichLab - 花呗前端团队招贤纳士 - 【转岗/内推/社招】孩子 你要相信光9 小时前
css之一个元素可以同时应用多个动画效果huangql5209 小时前
npm 发布流程——从创建组件到发布到 npm 仓库Days205010 小时前
LeaferJS好用的 Canvas 引擎小白菜学前端10 小时前
vue2 常用内置指令总结林_深时见鹿10 小时前
Vue + ElementPlus 自定义指令控制输入框只可以输入数字