npm使用国内淘宝镜像(最新地址)

目录

前言

一、命令配置

二、使用cnpm安装

三、常见包地址

四、总结

往期回顾


前言

我们前端程序员在使用国外的镜像源速度很慢并且容易下载失败,有时候需要尝试多次才有可能下载成功,很麻烦,但是可以切换为国内镜像源,下面我介绍下如何使用淘宝镜像源。

一、命令配置

设置淘宝镜像源

bash 复制代码
#最新地址 淘宝 NPM 镜像站喊你切换新域名啦!
npm config set registry https://registry.npmmirror.com

淘宝 NPM 镜像站喊你切换新域名啦!

注意:原域名https://registry.npm.taobao.org/ 在 2022.06.30 号正式下线和停止 DNS 解析

查看镜像使用状态

bash 复制代码
npm config get registry

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

那么如何恢复官方镜像源呢?

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

二、使用cnpm安装

安装cnpm

bash 复制代码
 npm install -g cnpm --registry=https://registry.npmmirror.com
 
 # 注册模块镜像
 npm set registry https://registry.npmmirror.com  

 // node-gyp 编译依赖的 node 源码镜像  
 npm set disturl https://npmmirror.com/dist 

 // 清空缓存  
 npm cache clean --force  

 // 安装cnpm  
 npm install -g cnpm --registry=https://registry.npmmirror.com  

淘宝 NPM 镜像站喊你切换新域名啦

注意:原域名https://registry.npm.taobao.org/** 在 2022.06.30 号正式下线和停止 DNS 解析**

使用cnpm

bash 复制代码
cnpm install xxx

三、常见包地址

自动化打包构建常见包配置地址 ,提高下载成功率!

bash 复制代码
# mirror config
sharp_binary_host = https://npmmirror.com/mirrors/sharp
sharp_libvips_binary_host = https://npmmirror.com/mirrors/sharp-libvips
profiler_binary_host_mirror = https://npmmirror.com/mirrors/node-inspector/
fse_binary_host_mirror = https://npmmirror.com/mirrors/fsevents
node_sqlite3_binary_host_mirror = https://npmmirror.com/mirrors
sqlite3_binary_host_mirror = https://npmmirror.com/mirrors
sqlite3_binary_site = https://npmmirror.com/mirrors/sqlite3
sass_binary_site = https://npmmirror.com/mirrors/node-sass
electron_mirror = https://npmmirror.com/mirrors/electron/
puppeteer_download_host = https://npmmirror.com/mirrors
chromedriver_cdnurl = https://npmmirror.com/mirrors/chromedriver
operadriver_cdnurl = https://npmmirror.com/mirrors/operadriver
phantomjs_cdnurl = https://npmmirror.com/mirrors/phantomjs
python_mirror = https://npmmirror.com/mirrors/python
registry = https://registry.npmmirror.com
disturl = https://npmmirror.com/dist

四、总结

通过上述的操作,我们可以轻松地配置和使用淘宝镜像来加速npm包的下载、安装和更新。

今天就分享到这里啦!欢迎在评论区交流。如果文章对你有所帮助,❤️关注+点赞❤️鼓励一下!博主会持续更新。。。。

我的博客:前端小阳仔_Html,CSS,JavaScript,Vue,React,Angular领域博主

往期回顾

css实现元素居中的6种方法

Angular8升级至Angular13遇到的问题

前端vscode必备插件(强烈推荐)

Webpack性能优化

vite构建如何兼容低版本浏览器

前端性能优化9大策略(面试一网打尽)!

vue3.x使用prerender-spa-plugin预渲染达到SEO优化

vite构建打包性能优化

vue3.x使用prerender-spa-plugin预渲染达到SEO优化

ES6实用的技巧和方法有哪些?

css超出部分显示省略号

vue3使用i18n 实现国际化

vue3中使用prismjs或者highlight.js实现代码高亮

什么是 XSS 攻击?什么是 CSRF?什么是点击劫持?如何防御

相关推荐
cv魔法师12 小时前
解决vscode终端报错npm : 无法加载文件npm.ps1,因为在此系统上禁止运行脚本。
ide·vscode·npm
夜雪闻竹3 天前
版本管理:npm 发布 + Electron 打包 + CI/CD
ci/cd·npm·node.js·代码规范·chatcrystal
zhangfeng11333 天前
workbuddy ,node.js 每次会在 项目目录上安装 node_modules,能不能一次安装多次使用,为什么 npm 不把包装在全局
前端·npm·node.js
步十人3 天前
【Vue3】前置知识简单概述(包括ES6核心语法,模块化ESM以及npm基础)
arcgis·npm·vue·es6
大貔貅喝啤酒4 天前
pip 国内镜像源大全【测试 / 自动化开发常备】
运维·自动化·pip·国内镜像源
小虎5 天前
npm和pnpm常用命令
npm·pnpm·镜像源·缓存目录
YJlio6 天前
OpenClaw 2026.5.2 Beta 更新解读:外部插件安装、ClawHub / npm 切换与 Gateway 性能优化
性能优化·npm·gateway·飞书·多维表格·飞书aily·飞书妙搭
丑过三八线6 天前
npm 私有仓库找不到包的解决方案
前端·npm·node.js
一天 24h6 天前
Vue3父子组件传值:从零到精通
前端·javascript·vue.js·pycharm·npm·学习方法
一点事6 天前
pnpm:离线环境项目如何安装pnpm依赖(官方推荐:离线镜像)
npm