electron-vite 安装, 打包下载资源失败,设置国内镜像

由于electron默认打包会从github上下载相关二进制包,众所周知,国内GitHub访问是相当慢的,所以经常会出现下载失败导致打包不成功,这时我们就需要配置国内的镜像源,以解决从GitHub下载慢甚至无法下载的问题。

修改npm配置文件(没有就创建):

npm的配置文件为用户根目录下的:~/.npmrc(Windows路径为:C:\Users<UserName>.npmrc)

加入以下内容:

1
2
3
4
5
6
7
8
9
10
11
prefix=/opt/node/global
cache=/opt/node/cache
registry=https://registry.npmmirror.com/
disturl=https://registry.npmmirror.com/-/binary/node/
sass_binary_site=https://registry.npmmirror.com/node-sass
phantomjs_cdnurl=https://registry.npmmirror.com/phantomjs
chromedriver_cdnurl=https://registry.npmmirror.com/-/binary/chromedriver/
operadriver_cdnurl=https://registry.npmmirror.com/-/binary/operadriver/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
always-auth=false

  


其中prefix是全局包 的路径,cache是缓存路径,这两个可以不配置。

这样再打包就不会报错了。
打包以下错误,要以管理员去运行 build

 

posted @   兔&&大梅  阅读(634)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示