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

相关推荐
啃火龙果的兔子1 天前
可以指定端口启动本地前端的npm包
前端·npm·node.js
我没想到原来他们都是一堆坏人2 天前
常用npm源与nrm
前端·npm·node.js
Lovely Ruby4 天前
[前端] 封装一下 echart 6,发布到 npm
前端·npm·node.js
BD_Marathon4 天前
NPM_常见命令
前端·npm·node.js
雪域迷影4 天前
怎么将.ts文件转换成.js文件?
javascript·typescript·npm·tsc
安_4 天前
为什么 Vue 要用 npm run dev 启动
前端·vue.js·npm
暴富的Tdy5 天前
【脚手架创建 Vue3 公共组件库】
前端·npm·npm发布
BD_Marathon5 天前
【JavaWeb】NPM_简介和相关配置
前端·npm·node.js
BD_Marathon5 天前
NPM_配置的补充说明
前端·npm·node.js
soul g6 天前
npm 包发布流程
前端·npm·node.js