一、通过命令配置
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
相关推荐
bearpping5 小时前
Nginx 配置:alias 和 root 的区别@大迁世界5 小时前
07.React 中的 createRoot 方法是什么?它具体如何运作?January12075 小时前
VBen Admin Select 选择框选中后仍然显示校验错误提示的解决方案. . . . .5 小时前
前端测试框架:Vitestxiaotao1315 小时前
什么是 Tailwind CSS战南诚6 小时前
VUE中,keep-alive组件与钩子函数的生命周期发现一只大呆瓜6 小时前
React-彻底搞懂 Redux:从单向数据流到 useReducer 的终极抉择霍理迪7 小时前
Vue的响应式和生命周期李剑一7 小时前
别再瞎写了!Cesium 模型 360° 环绕,4 套源码全公开,项目直接用