1

I am packaging a Meteor app using Electrify (by extension the Electron-Packager). Since the node module paths are too deep for Windows to accept, I added '--asar=true' as a packaging option.

Now when I try to start my packaged app, I get the following error:

shell.js: internal error
Error: ENOENT: no such file or directory, mkdir 'C:\Users\myusername\MyApp\.electrify\.dist\MyApp-win32-x64\resources\app.asar\db'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:799:18)
    at mkdirSyncRecursive 

...

        at Socket.g (events.js:260:16)
    module.js:338
        throw err;

It seems to have a problem with reading the asar file. Do you know any way to fix this?

Cos
  • 1,649
  • 1
  • 27
  • 50

1 Answers1

1

This kind of error can happen when you are including native modules in your application. Native modules require compilation against the OS-specific node that your app is built on. So, while you are compressing to ASAR, you must exclude any native modules that are in your project. This is done with the unpackDir option inside of the 'asar' option on your overall packager options. For example, in my gulp build I do something like this:

var gulp = require('gulp');
var $ = require('gulp-load-plugins')({lazy: true});
var config = require('./gulp.config')();
var packager = require('electron-packager');
var electronPackage = require('electron/package.json');
var electronVersion = electronPackage.version;
var pkg = require('./package.json');

// Build the electron app
gulp.task('build:electron', function(cb) {

    var opts = {
        name: pkg.name,
        platform: 'win32',
        arch: 'ia32',                           // ia32, x64 or all
        dir: config.root,                       // source location of app
        out: config.electronbuild,              // destination location for app os/native binaries
        ignore: config.electronignore,          // don't include these directories in the electron app build
        icon: config.icon,
        asar: {unpackDir: config.electroncompiled}, // compress project/modules into an asar blob but don't use asar to pack the native compiled modules
        overwrite: true,
        prune: true,
        electronVersion: electronVersion,       // Tell the packager what version of electron to build with
        'app-copyright': pkg.copyright,         // copyright info
        'app-version': pkg.version,             // The version of the application we are building
        win32metadata: {                        // Windows Only config data
            CompanyName: pkg.authors,
            ProductName: pkg.name,
            FileDescription: pkg.description,
            OriginalFilename: pkg.name + '.exe'
        }
    };

    packager(opts, function(err, appPath) {
        $.util.log(' <- packagerDone()', err, appPath);
        log(' all done!');
        cb();
    });

});

What is important for your case is the line for the asar option. You want to be sure that you do something like asar: {unpackDir: config.electroncompiled} , and simply replace the config.electroncompiled variable with your file glob of directories that include any natively compiled packages that your project uses (such things as libxml-xsd, libxmljs-mt, nslog etc). Hope that makes sense.

Kim Gentes
  • 1,496
  • 1
  • 18
  • 38