User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

How to install Electron?

Wed Jul 01, 2020 2:53 pm

I'm trying to convert all my Chrome Apps to Electron Apps, before RaspiOS's Chromium is upgraded to v80 (it's disabled from then on, because Google is killing Chrome Apps. :cry: )

The instructions say you need electron installed, and it is not. (bash says "command not found" when I try to type in 'electron')

And strangely, I can't seem to install electron. I tried this command:

Code: Select all

npm install -g electron
And here's the output:

Code: Select all

pi@raspberrypi:~/electron-chrome $ npm install -g electron
npm WARN checkPermissions Missing write access to /usr/lib
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/lib'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/lib']
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/lib\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2020-07-01T14_39_34_225Z-debug.log
OK, so maybe I have to run it as root:

Code: Select all

pi@raspberrypi:~/electron-chrome $ sudo npm install -g electron
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
npm WARN lifecycle The node binary used for scripts is /usr/local/bin/node but npm is using /usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> core-js@3.6.5 postinstall /usr/lib/node_modules/electron/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

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@9.0.5 postinstall /usr/lib/node_modules/electron
> node install.js

Error: EACCES: permission denied, mkdtemp '/usr/lib/node_modules/electron/electron-download-KQ0oj5'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@9.0.5 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@9.0.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-07-01T14_40_12_944Z-debug.log
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

pidd
Posts: 302
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 5:33 pm


User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 5:56 pm

pidd wrote:
Wed Jul 01, 2020 5:33 pm
Does this help? https://docs.npmjs.com/resolving-eacces ... s-globally
No. But I did some checking.

Code: Select all

$ apt search --names-only npm

npm/stable 5.8.0+ds6-4+deb10u1 all
  package manager for Node.js
How did npm even exist, if APT didn't install it? I don't remember compiling npm or anything... :?
Anyway, I've installed npm with APT, then plan on completely purging it. Then installing it again.
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26442
Joined: Sat Jul 30, 2011 7:41 pm

Re: How to install Electron?

Wed Jul 01, 2020 6:50 pm

Botspot wrote:
Wed Jul 01, 2020 5:56 pm
pidd wrote:
Wed Jul 01, 2020 5:33 pm
Does this help? https://docs.npmjs.com/resolving-eacces ... s-globally
No. But I did some checking.

Code: Select all

$ apt search --names-only npm

npm/stable 5.8.0+ds6-4+deb10u1 all
  package manager for Node.js
How did npm even exist, if APT didn't install it? I don't remember compiling npm or anything... :?
Anyway, I've installed npm with APT, then plan on completely purging it. Then installing it again.
It may have been installed as a dependency of something else. VSCode maybe? That uses Electron and needs NPM to build IIRC.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 7:11 pm

jamesh wrote:
Wed Jul 01, 2020 6:50 pm
Botspot wrote:
Wed Jul 01, 2020 5:56 pm
pidd wrote:
Wed Jul 01, 2020 5:33 pm
Does this help? https://docs.npmjs.com/resolving-eacces ... s-globally
No. But I did some checking.

Code: Select all

$ apt search --names-only npm

npm/stable 5.8.0+ds6-4+deb10u1 all
  package manager for Node.js
How did npm even exist, if APT didn't install it? I don't remember compiling npm or anything... :?
Anyway, I've installed npm with APT, then plan on completely purging it. Then installing it again.
It may have been installed as a dependency of something else.
If it had been installed as a dependency, wouldn't APT know about it? To APT, npm was not installed AT ALL, dependency or otherwise.
I'm currently repeating the install process on a fresh vdesktop virtual machine to see if the problem is repeated. It's possible my Desktop Pi has been messed up somehow.
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

pidd
Posts: 302
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 7:25 pm

Interesting, I have npm on one of my Pi4s and not the other, I wouldn't have chosen to install it so it must have come in with something else, I guess anything that uses Node.js.

I'm not even sure you should use npm any longer, isn't apt supposed to have replaced it in its entirety?

User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 7:28 pm

pidd wrote:
Wed Jul 01, 2020 7:25 pm
I'm not even sure you should use npm any longer, isn't apt supposed to have replaced it in its entirety?
IDK. Just frantically trying to port all my Chrome Apps before it's too late. Just following these instructions.

Edit: I think npm is required to install electron.
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 8:23 pm

SOLVED!
pidd wrote:
Wed Jul 01, 2020 5:33 pm
Does this help? https://docs.npmjs.com/resolving-eacces ... s-globally
No, but it made me think to try googling the eaccess error.
Here's the page that solved it for me: https://github.com/npm/npm/issues/17268 ... -310167614
The fix was:

Code: Select all

sudo npm install -g electron --unsafe-perm=true --allow-root
It worked perfectly! And now electron runs successfully.
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

User avatar
Botspot
Posts: 1241
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to install Electron?

Wed Jul 01, 2020 9:53 pm

Electron certainly works. This command opens a mini web browser showing the Google homepage:

Code: Select all

electron https://google.com
There are a few MESA errors, but it does load successfully.
Now to run electron-chrome's example:

Code: Select all

pi@raspberrypi:~/electron-chrome $ electron --enable-logging . --app-id=gidgenkbbabolejbgbpnhbimgjbffefm
using chrome runtime 1.3.6
chrome app id gidgenkbbabolejbgbpnhbimgjbffefm
chrome app directory /home/pi/.config/ElectronChrome/crx/gidgenkbbabolejbgbpnhbimgjbffefm/app-2.3.0.crx-unpacked
/home/pi/.config/ElectronChrome/crx/gidgenkbbabolejbgbpnhbimgjbffefm/app-2.3.0.crx-unpacked/native/linux/audio_playback.so not found.
/home/pi/electron-chrome/platform-assets/linux/audio_playback.so not found.
PPAPI path /home/pi/.config/ElectronChrome/crx/gidgenkbbabolejbgbpnhbimgjbffefm/app-2.3.0.crx-unpacked/native/linux/video_decode.so;application/x-ppapi-vysor
starting
registerprotocol
starting runtime
[4352:0701/163458.626315:INFO:CONSOLE(1)] "runtime started", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (1)
[4352:0701/163458.676881:INFO:CONSOLE(18)] "appId gidgenkbbabolejbgbpnhbimgjbffefm", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (18)
[4352:0701/163458.711199:INFO:CONSOLE(64)] "launchUrl: null", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (64)
[4352:0701/163458.712062:INFO:CONSOLE(99)] "chrome runtime started", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (99)
[4352:0701/163458.860946:INFO:CONSOLE(24)] "app icon: /home/pi/.config/ElectronChrome/crx/gidgenkbbabolejbgbpnhbimgjbffefm/app-2.3.0.crx-unpacked/icon.png", source: /home/pi/electron-chrome/chrome/api/chrome-app.js (24)
MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
[4352:0701/163459.129514:INFO:CONSOLE(365)] "initialized", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (365)
[4352:0701/163459.144557:INFO:CONSOLE(114)] "creating window __background", source: /home/pi/electron-chrome/chrome/api/chrome-app.js (114)
[4352:0701/163459.360984:INFO:CONSOLE(336)] "opening chrome-extension://gidgenkbbabolejbgbpnhbimgjbffefm/_generated_background_page.html", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (336)
[4352:0701/163459.399475:INFO:CONSOLE(1083)] "%cElectron Deprecation Warning font-weight: bold The 'remote' module is deprecated and will be disabled by default in a future version of Electron. To ensure a smooth upgrade and silence this warning, specify {enableRemoteModule: true} in the WebPreferences for this window.", source: electron/js2c/renderer_init.js (1083)
[4352:0701/163459.403237:INFO:CONSOLE(2601)] "%cElectron Security Warning (Disabled webSecurity) font-weight: bold; This renderer process has "webSecurity" disabled. This
  exposes users of this app to severe security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2601)
[4352:0701/163459.403787:INFO:CONSOLE(2630)] "%cElectron Security Warning (allowRunningInsecureContent) font-weight: bold; This renderer process has "allowRunningInsecureContent"
  enabled. This exposes users of this app to severe security risks.

  
For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2630)
[4352:0701/163459.404104:INFO:CONSOLE(2616)] "%cElectron Security Warning (Insecure Content-Security-Policy) font-weight: bold; This renderer process has either no Content Security
    Policy set or a policy with "unsafe-eval" enabled. This exposes users of
    this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2616)
MESA-LOADER: failed to open kms_swrast (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
failed to load swrast driver
[4352:0701/163459.928734:INFO:CONSOLE(2438)] "Uncaught (in promise) Error: ERR_BLOCKED_BY_CLIENT (-20) loading 'chrome-extension://gidgenkbbabolejbgbpnhbimgjbffefm/_generated_background_page.html'", source: electron/js2c/renderer_init.js (2438)
[4352:0701/163459.933599:INFO:CONSOLE(317)] "background onload", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (317)
[4352:0701/163459.940725:INFO:CONSOLE(1083)] "%cElectron Deprecation Warning font-weight: bold The 'remote' module is deprecated and will be disabled by default in a future version of Electron. To ensure a smooth upgrade and silence this warning, specify {enableRemoteModule: true} in the WebPreferences for this window.", source: electron/js2c/renderer_init.js (1083)
[4352:0701/163459.940984:INFO:CONSOLE(2601)] "%cElectron Security Warning (Disabled webSecurity) font-weight: bold; This renderer process has "webSecurity" disabled. This
  exposes users of this app to severe security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2601)
[4352:0701/163459.941139:INFO:CONSOLE(2630)] "%cElectron Security Warning (allowRunningInsecureContent) font-weight: bold; This renderer process has "allowRunningInsecureContent"
  enabled. This exposes users of this app to severe security risks.

  
For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2630)
[4352:0701/163459.941288:INFO:CONSOLE(2616)] "%cElectron Security Warning (Insecure Content-Security-Policy) font-weight: bold; This renderer process has either no Content Security
    Policy set or a policy with "unsafe-eval" enabled. This exposes users of
    this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (2616)
[4352:0701/163459.945605:INFO:CONSOLE(277)] "checking for updates to chrome app gidgenkbbabolejbgbpnhbimgjbffefm", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (277)
[4352:0701/163459.947699:INFO:CONSOLE(32)] "https://clients2.google.com/service/update2/crx?prodversion=83.0.4103.119&x=id%3Dgidgenkbbabolejbgbpnhbimgjbffefm%26installsource%3Dondemand%26uc%3D", source: /home/pi/electron-chrome/chrome/api/chrome-update.js (32)
[4352:0701/163500.100863:INFO:CONSOLE(42)] "server version", source: /home/pi/electron-chrome/chrome/api/chrome-update.js (42)
[4352:0701/163500.101002:INFO:CONSOLE(43)] "<?xml version="1.0" encoding="UTF-8"?><gupdate xmlns="http://www.google.com/update2/response" protocol="2.0" server="prod"><daystart elapsed_days="4930" elapsed_seconds="52500"/><app appid="gidgenkbbabolejbgbpnhbimgjbffefm" cohort="" cohortname="" status="ok"><updatecheck codebase="https://clients2.googleusercontent.com/crx/blobs/QwAAAHF3InbmK-wFIemaY3I3BCP-pEKWDDeSYiszC1Ot2CMO_ey7uPR4S6HRx0laYLbd8C8MgJG5XNRlmurykLEKsV_BGdn7CINYHmzy9s-B8reTAMZSmuV6tNjcT4vyffxpVM8CtpXZEh6eVA/extension_2_3_0_0.crx" fp="1.66a033b33862233b451118fe863fa77f93989c4d29e7fe0876f426db7bd0badf" hash_sha256="66a033b33862233b451118fe863fa77f93989c4d29e7fe0876f426db7bd0badf" protected="0" size="12135295" status="ok" version="2.3.0"/></app></gupdate>", source: /home/pi/electron-chrome/chrome/api/chrome-update.js (43)
[4352:0701/163500.116671:INFO:CONSOLE(142)] "latest version of gidgenkbbabolejbgbpnhbimgjbffefm 2.3.0 vs current 2.3.0", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (142)
[4352:0701/163509.169709:INFO:CONSOLE(220)] "shutting down", source: /home/pi/electron-chrome/chrome/api/chrome-runtime.js (220)
[4352:0701/163509.206301:INFO:CONSOLE(136)] "window closed __background", source: /home/pi/electron-chrome/chrome/api/chrome-app.js (136)
[4386:0701/163509.208098:WARNING:x11_util.cc(1520)] X error received: serial 452, error_code 170 (GLXBadWindow), request_code 152, minor_code 32 (Unknown)
[4386:0701/163509.209055:WARNING:x11_util.cc(1520)] X error received: serial 456, error_code 3 (BadWindow), request_code 4, minor_code 0 (Unknown)
killing all windows for shutdown
chromeRuntimeWindow shutdown
windows remaining [
  BrowserWindow {
    setBounds: [Function],
    _events: [Object: null prototype] {
      blur: [Function],
      focus: [Function],
      show: [Array],
      hide: [Function: visibilityChanged],
      minimize: [Function: visibilityChanged],
      maximize: [Function: visibilityChanged],
      restore: [Function: visibilityChanged],
      close: [Array]
    },
    _eventsCount: 8,
    devToolsWebContents: [Getter],
    _maxListeners: 1000
  }
]
window-all-closed
Nothing showed up. No window, nothing graphical. The terminal was returned to the prompt without any obvious hints as to what's wrong.
Want to make your own Raspbian image?
  • Hard way: Mess with confusing terminal commands.
  • Easy way: Let Pi-Power-Tools do it all for you!
Boot your image in a VM, Flash from the Internet at top speed, Mount (to drop files in), Edit partitions, Shrink/Expand, Repair, and more. Enjoy! :)
https://github.com/Botspot/Pi-Power-Tools

Return to “Beginners”