此Electron的安装方法是以统信UOS20专业版系统为例,安装方法仅供参考。
安装指定版本的nodejs
$ curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
$ sudo apt-get install -y nodejs
安装npm
$ sudo npm install -g npm
安装electron-builder和electron
$ sudo npm install -g electron-builder
$ sudo npm install -g electron@latest
验证electron是否正确安装
$ electron --version
如果执行“electron --version”出现如下错误异常
$ electron --version
[7477:0422/143336.089503:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /usr/lib/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.
/usr/lib/node_modules/electron/dist/electron exited with signal SIGTRAP
lindroid@lindroid-PC:~/Desktop$ [7480:0100/000000.105214:ERROR:zygote_linux.cc(672)] write: 断开的管道 (32)
执行如下命令解决此问题
$ sudo chown root /usr/lib/node_modules/electron/dist/chrome-sandbox && sudo chmod 4755 /usr/lib/node_modules/electron/dist/chrome-sandbox
$ electron --version
v30.0.1