在 raspberry pi 3 上安装电子 js 时出现问题

Problem installing electron js on raspberry pi 3

我在 raspberry pi 3 上安装了 node js,当我使用以下命令安装 electron js 时:

sudo npm install -g electron --unsafe-perm=true --allow-root

我得到以下输出:

/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js

> core-js@3.4.1 postinstall /usr/local/lib/node_modules/electron/node_modules/core-js
> node postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> electron@7.1.1 postinstall /usr/local/lib/node_modules/electron
> node install.js

(node:11878) UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/electron/node_modules/got/source/as-stream.js:35:24)
    at EventEmitter.emit (events.js:210:5)
    at module.exports (/usr/local/lib/node_modules/electron/node_modules/got/source/get-response.js:22:10)
    at ClientRequest.handleResponse (/usr/local/lib/node_modules/electron/node_modules/got/source/request-as-event-emitter.js:155:5)
    at Object.onceWrapper (events.js:300:26)
    at ClientRequest.emit (events.js:215:7)
    at ClientRequest.origin.emit (/usr/local/lib/node_modules/electron/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:583:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:17)
    at TLSSocket.socketOnData (_http_client.js:456:22)
(node:11878) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11878) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
+ electron@7.1.1
added 86 packages from 90 contributors in 39.202s

我该如何解决这个问题。

也许你可以下载 electron(和其他库)作为存档文件,复制到 raspberry 并安装。

  1. 下载
npm pack electron
  1. 复制electron-7.1.1.tgz

  2. 安装

npm install ./electron-7.1.1.tgz 

为了解决这个问题,我在项目根目录中创建了一个“.npmrc”文件并添加了:

arch=armv7l

您可以从以下位置获取 arch:

uname -m

尝试安装旧版本的电子。

npm install electron@6.1.4