App doesn't work after npm run build and create .exe


#1

Hi guys!
I’m working on electron and i have some problems with my database after create my .exe app.

First : if i use : electron . or npm start everything is OK!

I tried first do create my .exe with electron-packager and next with builder.

In both compilation : everything is OK, my .exe is created and i can launch it, my button redirect page is OK etc…
but all my database doesn’t work… :disappointed_relieved:

As you can see, everything is {{var}} and i can’t understand why… i’m so sad about it!

How it work ?
On my app.js :

 app.run(function($rootScope) {
   $rootScope.OsteoPro = "OsteoPro";
   $rootScope.pathBDD = "C:/Program Files (x86)/OsteoPro/database";
   $rootScope.nomBDD = "OsteoPro.db";

   try {
     var filebuffer = fs.readFileSync(path.resolve($rootScope.pathBDD, $rootScope.nomBDD));
   } catch (e) {
     console.log(e);
   }

   if (filebuffer != null) {
     var db = new SQL.Database(filebuffer);
   } else {
     var db = new SQL.Database();
   }
   $rootScope.db = db;
 });

:slight_smile: the {{title}} is $rootScope.OsteoPro --> it’s not a database value.
and $rootScope.db is my global var for my db. Example (in one of my controller.js):

var sql = "my sql";
  db.each(sql, function(row) {

Since everything works with npm start, i just think that my $rootScope doesn’t work on my .exe but why…

Thank you very much for your help !!


#2

I forgot one thing : in my controller.js, before my:
var sql = "my sql";

i just add :
var db = $rootScope.db;

Thank you!


#3

After that, i just try to put my database declaration in my controller.js (so without $rootScope) and nothing work too.

I look at my form and i see all the error messages are printed directly.

So i think, during my .exe build, something went wrong ? Maybe the compilation don’t take angular pluging ?

Need help please :slight_smile:


#4

i found the solution btw : https://github.com/baseljs/basel/issues/3

i use basel and that the probleme : copy the basel.json and the model folder : work fine for me :slight_smile: