nativefier / nativefier

Make any web page a desktop application
MIT License
34.9k stars 2.21k forks source link

Generated app from the Nativefier programmatic API doesn't seem to work #236

Open loulafripouille opened 8 years ago

loulafripouille commented 8 years ago

Description

It doesn't have the full directory skeleton (no locales/ and no resources/electron.asar): image

Steps to Reproduce Issue

generate an app with the API, just a little .js that called nativefier() method.

Specifications

thatkookooguy commented 8 years ago

I'm not sure what the problem is. Can you write down the actual command you used? did you just wrap facebook.com? did you try to add some command line arguments? which ones? did you get any execution errors?

If you executed something inside a node.js code, can you share that part of your code?

Everything looks good to me when I run nativefier "http://www.facebook.com" --name "Facebook" on Windows and OS X This is my folder structure:

facebookbug
loulafripouille commented 8 years ago

Yes, you right, with the cli interface there is no problem!

I don't use the comand line to generate that and get this issue. I use the js API

Options that I pass:

var options = {
    name: 'facebook',
    targetUrl: 'http://www.facebook.com',
    platform: 'default value',
    arch: 'default value',
    version: 'default value',
    out: '.',
    overwrite: default value,
    asar: default value,
    icon: 'default value',
    counter: default value,
    width: default value,
    height: default value,
    showMenuBar: default value,
    fastQuit: default value,
    userAgent: 'default value'
    ignoreCertificate: default value,
    insecure: default value,
    honest: default value,
    zoom: default value
};

Thank you

thatkookooguy commented 8 years ago

Can you please share more than that? the options you pass don't help us help (since most if it is just the defaults). What kind of error message does the function returns? Or, is there any error printed out to the console?

loulafripouille commented 8 years ago

No error, aside from this issue. So to avoid this, I just remove the progress call in the nativefier file (build***.js) temporarily.

Then, all run correctly, no error provides by the callback. But the app is not well generated. So, I have no more that to give you.

melvin0008 commented 7 years ago

Thanks for nativefier. Its amazing. :)

I faced the same issue when I use the API for many such websites.

arkhenstone commented 6 years ago

To replicate, build a nodejs app with the code provided as example in the bottom of the API documentation. Not CLI. @Thatkookooguy

I face the same issue. Got this from the cmd (windows 7)

Error: Invalid package C:\Users\***\Desktop\win32-x64-template\resources\default_app.asar
    at invalidArchiveError (ELECTRON_ASAR.js:153:19)
    at Object.module.(anonymous function) [as open] (ELECTRON_ASAR.js:209:16)
    at WriteStream.open (fs.js:2111:6)
    at new WriteStream (fs.js:2097:10)
    at Object.fs.createWriteStream (fs.js:2059:10)
    at writeStream (C:\Users\***\dev\nativefier-gui\node_modules\extract-zip\index.js:175:36)
    at C:\Users\***\dev\nativefier-gui\node_modules\extract-zip\index.js:172:18
    at C:\Users\***\dev\nativefier-gui\node_modules\yauzl\index.js:439:7
    at C:\Users\***\dev\nativefier-gui\node_modules\yauzl\index.js:473:5
    at C:\Users\***\dev\nativefier-gui\node_modules\fd-slicer\index.js:32:7
    at FSReqWrap.wrapper [as oncomplete] (fs.js:664:17)

EDIT : Same for linux Nativefier : 7.6.1 Node : 9.5.0

Error: Invalid package /home/***/Développement/nativefier-build/linux-x64-template/resources/default_app.asar
    at invalidArchiveError (ELECTRON_ASAR.js:153:19)
    at Object.module.(anonymous function) [as open] (ELECTRON_ASAR.js:209:16)
    at WriteStream.open (fs.js:2111:6)
    at new WriteStream (fs.js:2097:10)
    at Object.fs.createWriteStream (fs.js:2059:10)
    at writeStream (/home/brice/Développement/nativefier-gui/node_modules/extract-zip/index.js:175:36)
    at /home/***/Développement/nativefier-gui/node_modules/extract-zip/index.js:172:18
    at /home/***/Développement/nativefier-gui/node_modules/yauzl/index.js:439:7
    at /home/***/Développement/nativefier-gui/node_modules/yauzl/index.js:473:5
    at /home/***/Développement/nativefier-gui/node_modules/fd-slicer/index.js:32:7
    at FSReqWrap.wrapper [as oncomplete] (fs.js:664:17)

Folder is generated in desktop and seems to have everything, but subfolder (resource) is empty. Works nice if used by CLI.

Found maybe something relevant with an issue in electron version it seems :

Invalid package name.asar at invalidArchiveError

jahumes commented 6 years ago

For everyone that is having an issue, the cause is due to the Electron file system being unable to unzip an asar file which is required for electron-packager to work. The solution is to spin up a child process, turn off the asar functionality for that child, and then run it.

const child_process = require('child_process');
const child = child_process.fork(join(__dirname, 'compileApp.js'));

And then in the child process, doing the logic needed to run nativefier.

process.noAsar = true;

const options = {
  targetUrl: 'http://mail.google.com',
  overwrite: true,
  inject: []
  // asar: false,
  // out: '../../../',
  // fileDownloadOptions: {
  //   saveAs: true
  // }
};

nativefier(options, (error, appPath) => {
  if (error) {
    console.error(error);
    return;
  }
  console.log('App has been nativefied to', appPath);
});