How to run Aurelia app with Electron?
Asked Answered
C

2

6

I used the Aurelia CLI to create a default Hello World app that was confirmed running using Aurelia.

Aurelia generated a index.html in the root directory as such:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Aurelia</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>

  <body aurelia-app="main">
    <script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
  </body>
</html>

From there I simply created a main.js based off of the Electron QuickStart main.js and installed Electron using npm install --save-dev. I set main.js to being the driver of the project and launched Electron.

The app index was opened, however, Electron was just blank. What are the proper steps in getting Aurelia working with Electron?

I've created a few basic JavaScript projects using Electron, but I can't seem to get other web apps to run. Same goes with Angular.

Node has been screaming about :

(node:5372) Warning: a promise was rejected with a non-error: [object String]
process.on @ internal/process/warning.js:21

and an issue with PLATFORM.Loader:

Unhandled rejection No PLATFORM.Loader is defined and there is neither a System API (ES6) or a Require API (AMD) globally available to load your app.
printWarning @ vendor-bundle.js:1386
Cutty answered 7/6, 2017 at 23:38 Comment(2)
First, see what's in the console in electron by pressing Ctrl+Shift+ICulpable
Node is warning about a promise being rejected with a non-error and I'm getting a printWarning from vendor-bundle.js about PLATFORM.Loader.Cutty
C
1

Could you try updating your html-webpack-plugin to the most recent version? I think this is a webpack config issue.

Cata answered 26/9, 2017 at 15:32 Comment(1)
I can't speak for Wotsa, but in my scenario I was using RequireJs, not webpack. The error doesn't occur when using SystemJs, so that's the route I've gone down for now.Tropo
F
0

I just ran into this, and followed the notes in https://github.com/electron/electron/issues/303 which helped me. Note: "require" was undefined for me so I had to change it to

window.nodeRequire = window.require || {};

and I do not know what implication this has on my using node APIs from the app, but I do have my "Hello World" Aurelia app running now with NodeJS and Electron 3.0.0 beta-1.

Update: I believe the missing window.require was because in the main.js I had webPreferences: false. Removing this removed this restriction.

Forsake answered 3/7, 2018 at 19:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.