切换淘宝最新npm镜像源

👨‍⚕️ 主页: gis分享者

👨‍⚕️ 感谢各位大佬 点赞👍 收藏⭐ 留言📝 加关注✅!

👨‍⚕️ 收录于专栏:前端工程师


文章目录


一、🌎前言

  • NPM(Node Package Manager),是NodeJs的模块依赖管理工具,用于nodejs模块的安装、更新和卸载等。
  • 镜像源是软件包管理工具用来下载和安装软件包的服务器地址。由于网络原因,直接使用官方源可能会导致速度慢或连接失败的问题。国内镜像源可以提供更快的访问速度和更稳定的连接。
  • npm install 安装插件时,从默认npm镜像源获取数据,通常为国外镜像源,这就导致一个问题,访问速度很慢或者干脆超时中断。这时切换到国内npm镜像源,很有必要,国内镜像源有速度快、稳定的特点,本文以切换淘npm镜像源为例介绍如何切换npm镜像源。

二、🌎切换淘宝最新npm镜像源

2.1 🪐查询最新镜像源

通过百度或者官网查询淘宝最新npm镜像源,验证镜像源地址是否过期可用

例如:https://registry.npmmirror.com

提醒已经过期,证明当前镜像源地址不可用

最新淘宝镜像地址:

https://registry.npmmirror.com

返回正确的页面,证明可用

2.2 🪐两种方式切换npm镜像源

2.2.1 💫通过npm配置

查看当前镜像源

yaml 复制代码
npm config get registry

设置淘宝镜像源

yaml 复制代码
npm config set registry https://registry.npmmirror.com/

删除淘宝镜像源

yaml 复制代码
npm config delete registry https://registry.npmmirror.com

查看当前镜像源

yaml 复制代码
npm config get registry

切换到官方npm镜像源

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

设置/切换淘宝镜像源

yaml 复制代码
npm config set registry https://registry.npmmirror.com/

删除淘宝镜像源

yaml 复制代码
npm config delete registry https://registry.npmmirror.com/

2.2.1 💫通过cnpm配置

通过cnpm使用淘宝镜像:

yaml 复制代码
npm install -g cnpm --registry=https://registry.npmmirror.com

将npm设置为淘宝镜像:

yaml 复制代码
npm config set registry https://registry.npmmirror.com

查看npm镜像设置:

yaml 复制代码
npm config get registry 

查看cnpm镜像设置:

yaml 复制代码
cnpm config get registry 

cnpm安装插件:

yaml 复制代码
cnpm install xxx

三、🌎总结

以上为切换切换淘宝最新npm镜像源的方法,其他国内npm镜像源切换方法同理,希望对您有帮助~

相关推荐
无责任此方_修行中12 小时前
如何利用 pnpm 的安全控制功能防御 npm 供应链攻击
javascript·npm·node.js
臣妾没空2 天前
里程碑5:完成框架npm包抽象封装并发布
前端·npm
sudo_jin2 天前
前端包管理器演进史:为什么 npm 之后,Yarn 和 pnpm 成了新宠?
前端·npm
codingWhat5 天前
前端组件库开发实践:从零到发布
前端·npm·vite
vivo互联网技术6 天前
深度解析悟空系统多机房部署共线改造
前端·npm·多语言·共线改造·多机房
汐瀼7 天前
【AI个人学习】npm本地安装claude code白嫖minimax模型
前端·学习·npm
硬汉嵌入式8 天前
MDK6的pack包管理组件Arm Device Manager转战npm做系统管理,解决下载卡顿,慢的问题
npm·mdk6
日光倾8 天前
【Vue.js 入门笔记】NPM入门
vue.js·笔记·npm
受打击无法动弹11 天前
Window 10部署openclaw报错node.exe : npm error code 128
npm·node.js·openclaw