npm使用国内淘宝镜像的方法整理

命令配置安装:

淘宝镜像:

复制代码
npm config set registry https://registry.npm.taobao.org/

官方镜像:

复制代码
npm config set registry https://registry.npmjs.org

通过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  

//使用:
cnpm install xxx

查看镜像:

复制代码
npm config get registry

像我使用的是淘宝镜像,返回结果如下:

如果返回https://registry.npm.taobao.org/,说明配置的是淘宝镜像。

如果返回https://registry.npmjs.org/,说明配置的是淘宝镜像。

相关推荐
没事别瞎琢磨18 分钟前
十一、审计与 Run Session——每一步操作都被记录
人工智能·node.js
naildingding18 分钟前
3-ts接口 Interface
前端·typescript
没事别瞎琢磨18 分钟前
十六、AgentSandbox——把所有模块串起来的编排类
人工智能·node.js
没事别瞎琢磨23 分钟前
十二、网络代理与白名单规则引擎
人工智能·node.js
小小前端仔LC25 分钟前
Node.js + LangChain + React:搭建个人知识库(六)- “吃什么”项目实战:从700+菜谱入库到Taro H5端JSON渲染
前端·后端
没事别瞎琢磨27 分钟前
十四、Git Worktree 隔离执行
人工智能·node.js
晓131342 分钟前
【Cocos Creator 3.x】篇——第二章 入门
前端·javascript·游戏引擎
程序员黑豆1 小时前
AI全栈开发之Java:怎么配置Java环境变量
前端·后端·ai编程
xiaofeichaichai1 小时前
React Hooks
前端·javascript·react.js
问心无愧05132 小时前
ctf show web入门110
前端·笔记