简体   繁体   中英

How to run Aurelia app with Electron?

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM