Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error starting electron app on new projects (capacitor 6) : UnhandledPromiseRejection on /live-runner.js #284

Open
hatsantos opened this issue Apr 16, 2024 · 7 comments

Comments

@hatsantos
Copy link

Describe the bug
When starting a new ionic app and adding a electron capacitor plataform an erro happens when trying to start the electron app.
Yesterday Capacitor 6 was released. I don't know if it related to this new version.

npx cap open @capacitor-community/electron

ℹ Opening Electron platform: start 🚀
ℹ Opening Electron platform: building electron app
⠸ Opening Electron platform: running electron appError: undefined
✖ Opening Electron platform:
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: 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(). The promise rejected with the reason "
> [email protected] electron:start-live
> node ./live-runner.js

node:internal/child_process:421
    throw new ErrnoException(err, 'spawn');
          ^

Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at Object.spawn (node:child_process:761:9)
    at D:\TesteXPTO\electron\live-runner.js:19:24
    at new Promise (<anonymous>)
    at runBuild (D:\TesteXPTO\electron\live-runner.js:18:10)
    at D:\TesteXPTO\electron\live-runner.js:72:9
    at Object.<anonymous> (D:\TesteXPTO\electron\live-runner.js:75:3)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32) {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawn'
}

Node.js v20.12.2
".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v20.12.2

To Reproduce
ionic start > angular > XPTOapp > standalone
ionic build --prod
npm i @capacitor-community/electron
npx cap add @capacitor-community/electron
npx cap open @capacitor-community/electron

Expected behavior
Build should happen and app should start.

Screenshots

image

Desktop (please complete the following information):

 Version 22H2
 
 Ionic:
   Ionic CLI                     : 7.2.0 (C:\Users\hsantos\AppData\Local\pnpm\global\5\.pnpm\@[email protected]\node_modules\@ionic\cli)        
   Ionic Framework               : @ionic/angular 7.8.4
   @angular-devkit/build-angular : 17.3.4
   @angular-devkit/schematics    : 17.3.4
   @angular/cli                  : 17.3.4
   @ionic/angular-toolkit        : 11.0.1

Capacitor:
   Capacitor CLI      : 6.0.0
   @capacitor/android : 6.0.0
   @capacitor/core    : 6.0.0
   @capacitor/ios     : not installed

Utility:
   cordova-res : not installed globally
   native-run  : 2.0.1

System:
   NodeJS : v20.12.2 (C:\Program Files\nodejs\node.exe)
   npm    : 10.5.0
@hatsantos
Copy link
Author

I think it's related with the node version... The latest LTS seems to crash the build.

@satheshsat
Copy link

I am also getting same error. My node version is Node.js v18.20.2

@jduerr
Copy link

jduerr commented May 31, 2024

Experiencing the exact same error.
Did anybody find a working solution?

@ethrythedev
Copy link

Same error, node v20.12.2

@hatsantos
Copy link
Author

I had to downgrade to node version 18.19.0 to make it work.

@TruongHaiDang
Copy link

I had to downgrade to node version 18.19.0 to make it work.

Thanks you. It work for me.

@Frooger
Copy link

Frooger commented Dec 4, 2024

you can fix it by change line 19 in live-runner.js
from
let tempChild = cp.spawn(npmCmd, ['run', 'build']);
to
let tempChild = cp.spawn(npmCmd, ['run', 'build'], {shell: true});

https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants