Search code examples
node.jsnpmelectronraspbian

Why can't I run same app in the Rasspian OS?


I developed a desktop app with using Electron js. I developed it MacOS and Windows. I was copying the main.js, main.html and renderer.js. While I was changing the computer I was using

npm rebuild

then I was running the project by using

npm start

I also tested it on Ubuntu. It also works. However when I tried it on Rasspberry Pi 3 B+ with Raspian OS, I can't run it. The error is below. Thank you guys in advance.

> ls@1.0.0 start /home/pi/Desktop/deneme
> electron .

/home/pi/Desktop/deneme/node_modules/electron/index.js:14
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
    ^

Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
    at getElectronPath (/home/pi/Desktop/deneme/node_modules/electron/index.js:14:11)
    at Object.<anonymous> (/home/pi/Desktop/deneme/node_modules/electron/index.js:18:18)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
    at Module.load (internal/modules/cjs/loader.js:914:32)
    at Function.Module._load (internal/modules/cjs/loader.js:822:14)
    at Module.require (internal/modules/cjs/loader.js:956:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/pi/Desktop/deneme/node_modules/electron/cli.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ls@1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ls@1.0.0 start 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!     /home/pi/.npm/_logs/2019-11-13T12_15_05_388Z-debug.log

I tried many times, deleting and reinstalling node modules. Also I tried different node versions. Here also my versions:

node -v
V13.1.0
npm -v
V6.12.1

I can't even run the https://github.com/electron/electron-quick-start . I think the problem is with my operation system.


Solution

  • Newer versions of Electron are apparently not compatible with Raspbian. Thus, I have installed Electron 3.0.13 which is the last version I have found to be working.

    To change the Electron version, delete the node_modules folder and package-lock.js, open your package.json and modify it like below:

    "electron": "3.0.13" 
    

    Then run

    npm install
    

    to download and install the correct version of Electron and the app will run fine on Raspbian.