切换淘宝最新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镜像源切换方法同理,希望对您有帮助~

相关推荐
晨欣2 天前
pnpm vs npm 命令对照表
前端·npm·node.js
奔跑的web.2 天前
npm install发生了什么?
前端·npm·node.js
zhengxianyi5152 天前
npmjs切换淘宝镜像
前端·npm·npm安装源
梁萌3 天前
vue项目从npm升级为pnpm
前端·npm·node.js
墨着染霜华3 天前
npm-cache 怎么迁移出C盘
npm·node.js
catoop3 天前
npm 离线安装软件包指南(离线安装 claude code)
npm·node.js
老前端的功夫3 天前
抛弃 `!important`,让 CSS 优先级变大
前端·javascript·css·npm·node.js
二哈喇子!3 天前
使用NVM下载Node.js管理多版本
前端·npm·node.js
摇滚侠5 天前
Node.js 零基础教程,Node.js 和 NPM 的安装与使用
前端·npm·node.js
ghgxm5206 天前
Fastapi_00_学习策略与学习计划
python·学习·前端框架·npm·fastapi