vendredi 9 mars 2018

Electron require external javascript file outside app

I want to require an external javascript file in ember electron that is located outside the release app. So the user can adapt this javascript file without rebuilding the whole app.

The file should sit in some directory of the users computer within/linksAlgs/sayhello.js In linksAlgs I have also a package.json

What I have tried so far in Ember controller.js:

var sayHi = requireNode(__dirname +'/linksAlgs/sayhello');

sayHello(){
  this.set('greeting', sayHi.sayhello());
  var greetings = sayHi.sayhellolog();
  console.log(greetings);

},

part of package.json of app:

"scripts": {
"build": "ember build && extraResources: [./linksAlgs/**]",
"lint:js": "eslint ./*.js app config lib server tests",
"start": "ember serve",
"test": "ember test"
},

But then I get the error enter image description here

When I try this in Ember controller.js:

var sayHi = requireNode('sayhello');

 sayHello(){
  this.set('greeting', sayHi.sayhello());
  var greetings = sayHi.sayhellolog();
  console.log(greetings);

},

part of package.js of app:

"scripts": {
"build": "ember build",
"lint:js": "eslint ./*.js app config lib server tests",
"start": "ember serve && npm install ../linksAlgs/sayhello  --save",
"test": "ember test"

},

Then I get this error: enter image description here

So it searches in the wrong directory. How can I achieve a correct require of an external javascript file (outside the release app) in electron (with ember)? Thanks!




Aucun commentaire:

Enregistrer un commentaire