Electron-builder: node-pre-gyp stripped in packed dir

Created on 11 Jul 2017  Â·  8Comments  Â·  Source: electron-userland/electron-builder

  • Version: 19.15.2
  • Target: Windows x64

node_modules/node-pre-gyp is being stripped from the built dir win-unpacked

I have tried placing 'node_modules/node-pre-gyp' into asarUnpack, but it is still missing from app.asar.unpacked and app.asar.

It is required by module 'sqlite3'.

Other modules I specify in asarUnpack are placed in app.asar.unpacked.

bug

Most helpful comment

Fixed in 19.15.5

All 8 comments

partial 'build' fragment:

    "asarUnpack": [
        "node_modules/rx-dom",
        "node_modules/fsevents",
        "node_modules/sqlite3",
        "node_modules/node-pre-gyp"
    ],

Aside from node-pre-gyp missing from built package dir, the other modules are still being placed in app.asar as well as app.asar.unpacked.
require('sqlite3') is picking up version inside app.asar, but I have placed a copy of node-pre-gyp dir into app.asar.unpacked, so it does not get required, resulting in an error.

Ok, I have now discovered that your packing logic strips out sub node_modules.
In this case sqlite3/node_modules is removed, which contains node-pre-gyp.
Copying it back in manually fixes things.

I would have to spend a lot of time tracing through electron-builder code to understand what is happening, @develar can you please provide a summary of what you think and how to fix this?

Thanks for using prerelease, node-pre-gup is filtered out because not required for production. Yeah, I will check why sql requires it.

This is top the of main file for sqlite3, no way to avoid it.

var binary = require('node-pre-gyp');
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));

Ok, node-pre-gyp should be not used — prebuild is much better. But we cannot teach users and fight with existing modules. I will release 19.5.5 in several hours. prebuild will be still removed to reduce app size. Someday someone will fix sqlite3.

Thanks!

Fixed in 19.15.5

Works great, thanks @develar for the super awesome quick fix.
I will make a donation next week using hopefully proceeds of product sales.

Was this page helpful?
0 / 5 - 0 ratings