在Ubuntu上安装Electron

10

当我尝试在Ubuntu 15.04上使用以下命令安装electron:

sudo npm install electron-prebuilt -g

我得到了如下结果:

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

> electron-prebuilt@0.28.3 postinstall /usr/local/lib/node_modules/electron-prebuilt
> node install.js

Downloading electron-v0.28.3-linux-x64.zip
Error: tunneling socket could not be established, cause=139936635598656:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:795:


/usr/local/lib/node_modules/electron-prebuilt/install.js:15
  throw err
        ^
Error: tunneling socket could not be established, cause=139936635598656:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:795:

npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! electron-prebuilt@0.28.3 postinstall: `node install.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the electron-prebuilt@0.28.3 postinstall script.
npm ERR! This is most likely a problem with the electron-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls electron-prebuilt
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.19.0-18-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "electron-prebuilt"
npm ERR! cwd /usr/bin
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/bin/npm-debug.log
npm ERR! not ok code 0

我尝试了:

/usr/bin/文件夹中使用命令:ln -s node nodejs 为节点创建系统链接,以及

按照这里的建议,安装了node-legacy包:sudo apt-get install node-legacy,但没有成功。

在其他论坛上也找不到更多信息。请帮忙,先感谢。

8个回答

9
以下步骤适用于我: (假设已经安装了node和npm)
  1. 更新npm包至最新版:

    sudo npm install npm@latest -g

  2. 使用以下开关安装electron:

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

有经验的人对此进行更正/建议时,我们非常欢迎。希望这能帮助到某些人。

2
对我有用的唯一答案(解决ELIFECYCLE错误)。谢谢! - Jos

4

2

很可能你在使用代理。

你可以禁用代理或者让npm在代理下工作(参见这个问题)。


是的,我确实在代理后面,但我已经设置了所有的配置,其他应用程序使用npm安装得非常好。 - ant_1618
假设您已经按照提到的帖子中的说明操作,但仍然无法解决问题 - 您能否禁用此代理?附注:我刚刚在全新的Ubuntu上安装了electron-prebuild,只需安装node、npm并将nodejs链接到node,就像您描述的那样。因此,我相信这仍然是代理问题。 - kyrisu
我的网络是由我的学院通过代理服务器提供的,所以我无法禁用它。我必须从代理服务器后面解决所有问题。 另外,您认为代理服务器会对不同的应用程序产生不同的影响吗?因为正如我所提到的,我尝试安装其他模块,并且没有出现任何错误或警告。 - ant_1618
从您的输出来看,它似乎仍然存在 SSL 问题 - 这可能是因为 electron-download 在下载 electron-prebuild 时使用了它。您可以尝试从 http 镜像下载 electron,如下所示:设置 ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/ && npm install electron-prebuild。 - kyrisu
electron-prebuilt 还运行一个脚本,该脚本从 AWS 获取二进制文件。您可能想查看此链接:https://github.com/mafintosh/electron-prebuilt/issues/21 - justin.m.chase

0

您输入有误,请安装nodejs-legacy

sudo apt-get install nodejs-legacy

修复它,然后继续安装电子

sudo npm install electron-prebuilt -g

0
sudo npm install electron -g

这对我有用


0

我来到这里是因为我的最终应用程序在Ubuntu上无法安装。 如果有人遇到同样的问题,请前往构建位置并使用终端运行以下命令: sudo dpkg -i <您的安装/构建文件名称> 附言:我在其他地方没有找到这个解决方案,这就是为什么我在这里发布它的原因。


0

首先通过以下方式安装最新版的nodenpm

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
$ sudo apt-get install -y nodejs

最新的npm版本现在是6.9.0,使用npm --version检查npm版本 如果npm版本6.4.1,只需首先通过以下方式更新npm

$ npm install -g npm

如果您因sudo权限问题而遇到问题,那么您可以cd进入.npm-global
$ cd /home/user_home_directory/.npm-global/

使用chmod命令更改此文件夹中所有文件和目录的权限:

$ sudo chmod 777 * -R

安装后,您必须将此行添加到.bashrc文件的末尾:

export PATH="/home/user_home_directory/.npm-global/bin:$PATH"

保存 .bashrc 后,只需通过 source 调用它即可

$ source .bashrc

完成所有操作后,您可以通过以下方式全局安装electron

$ npm install -g electron

0

使用这个对我很有帮助:

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

没有使用--unsafe-perm=true --allow-root,我会收到以下错误信息:

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

Error: EACCES: permission denied, mkdtemp 
'/usr/local/lib/node_modules/electron/electron-download-rSlUcU'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@10.1.5 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@10.1.5 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-13T04_43_27_809Z-debug.log

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接