Friday 2 June 2017

Electron putting node_modules in asar fails module dependencies

I've got an Electron project in node.js and am currently attempting to make distribution easier by collapsing the massive node_modules hierarchy into an asar. This way I can have app.asar and modules.asar, as suggested by various places such as grunt-asar.

The problem is that this needs me to change all require() statements to have the asar in the path, like: require('modules.asar/package'). That's fine for modules I'm including from my code but when a module itself uses require('dependency-package') that then fails to resolve. As I understand it, node.js will resolve in the "node_modules" folder for these but there is no "node_modules" directory anymore due to packaging modules into an asar.

Is there anything I can do to help this?



via Dave

No comments:

Post a Comment