MacOS下全局安装Electron失败,遇404错误求助
Electron全局安装404错误的解决办法
错误原因
你遇到的404错误核心原因是:Electron v19.0.9并未提供32位macOS(darwin-ia32)的安装包。目前macOS系统早已全面淘汰32位应用支持,官方也停止了对应架构的安装包分发。
解决步骤
- 指定64位架构安装:
安装时强制指定64位架构,执行命令:npm install -g electron --arch=x64 - 升级到最新稳定版Electron:
旧版本可能存在架构支持遗留问题,直接安装最新版:npm install -g electron@latest - 清理npm缓存后重试:
若缓存中残留错误的下载路径,先清理缓存再安装:npm cache clean --force npm install -g electron - 切换国内镜像源(网络问题时用):
如果是网络无法访问GitHub资源导致的问题,可切换国内镜像:npm config set electron_mirror=https://npmmirror.com/mirrors/electron/ npm install -g electron
报错原文:
npm ERR! code 1 npm ERR! path /usr/local/lib/node_modules/electron npm ERR! command failed npm ERR! command sh -c node install.js npm ERR! HTTPError: Response code 404 (Not Found) for https://github.com/electron/electron/releases/download/v19.0.9/electron-v19.0.9-darwin-ia32.zip npm ERR! at EventEmitter.<anonymous> (/usr/local/lib/node_modules/electron/node_modules/got/source/as-stream.js:35:24) npm ERR! at EventEmitter.emit (node:events:390:28) npm ERR! at module.exports (/usr/local/lib/node_modules/electron/node_modules/got/source/get-response.js:22:10) npm ERR! at ClientRequest.handleResponse (/usr/local/lib/node_modules/electron/node_modules/got/source/request-as-event-emitter.js:155:5) npm ERR! at Object.onceWrapper (node:events:510:26) npm ERR! at ClientRequest.emit (node:events:402:35) npm ERR! at ClientRequest.origin.emit (/usr/local/lib/node_modules/electron/node_modules/@szmarczak/http-timer/source/index.js:37:11) npm ERR! at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:623:27) npm ERR! at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17) npm ERR! at TLSSocket.socketOnData (node:_http_client:487:22) npm ERR! A complete log of this run can be found in:
内容的提问来源于stack exchange,提问作者Big Bored
相关产品推荐
相关产品推荐

