One of my node modules is linked via npm link and I get an error during build:
> build --dir
Skip app dependencies rebuild because dev and app dependencies are not separated
Packaging for platform darwin x64 using electron 1.3.3 to dist/mac
Error: /Users/anri/myapp/node_modules/myapp-lib: file links out of the package
at Filesystem.insertLink (/Users/anri/myapp/node_modules/asar-electron-builder/lib/filesystem.js:82:15)
at /Users/anri/myapp/node_modules/electron-builder/src/asarUtil.ts:316:28
at next (native)...
Without linking it works fine.
Would also love to see a fix for this since it worked before in 4.x.
I don't think this is ASAR-specific -- it's just that the error is more noisy when ASAR is enabled. It looks like the symlink just isn't getting dereferenced / followed.
Packaging succeeds when ASAR is disabled, but that's because it just includes the addon's symlink in the app bundle as-is. In my case the symlink is relative, so the resulting bundle can't load the linked addon when it's installed in Applications as usual.
@cwillisf check this out (link to source inside): https://github.com/electron/asar/issues/85
Working on fix.
BTW, you should never build production builds using npm linked modules.
I know, but its convenient for developing sometimes : )
@develar Well, if you bundle everything and keep everything in 'devDependencies' then it's fine.
@anri-asaturov No. Linked module copied AS IS, as the whole project โ all node module development files, all node module dependencies including development โ not pruned and not optimised (duplicated) will be included to production app.
@develar i understand, but i don't have any 'dependencies' in my package.json and therefore no 'node-modules' in built app. Everything is bundled with webpack to 2 files 'electron.js' and 'renderer.js'. Why would 'devDependencies' get copied by electron-builder? They don't.
@anri-asaturov So, your issue is completely different. Please attach sample project. If "i don't have any 'dependencies' in my package.json and therefore no 'node-modules' in built app" then electron-builder must not try to pack your linked module at all.
@develar yes, you are right, I wasn't bundling electron process code when I stumbled into this problem, then I started bundling it too to avoid this issue. Sorry to cause confusion.
next version: Set build.dereference to true and disable asar as workaround. Moved to backlog โ a lot of more important issues should be solved. PR is welcome.
Any hints on how to potentially fix the 'copy as is' issue with linked packages? I could try to fix it.
@anri-asaturov Please clarify โ is your statement i don't have any 'dependencies' in my package.json and therefore no 'node-modules' in built app still true or not.
Currently, for the project I initially opened this issue for it's true, it's my workaround.
But I'd like to switch back to linked module because now i have to push/publish my dependency every time I change it or I have to bundle electron process code.
Not clear for me โ why you need to have packed app often. Why you cannot use electron-prebuilt?
In any case โ there is a workaround โ build.dereference added for you. Disable asar:
"asar": false,
"dereference": true
add this to your build. Next version will be published soon. Is it suitable for you?
Any hints on how to potentially fix the 'copy as is' issue with linked packages?
This issue in any case should be fixed before, right?
Linked module is supported in the upcoming electron-builder 11.2.0.
Please note โ linked module packed AS IS. Package module dir copied AS IS, not as result of npm pack (i.e. as production). i.e. if your module has dir src that compiled into out, both dirs will be packed into your app. Solution โ configure files option to exclude extraneous files.
I'm still facing the same problem with electron-builder 19.24.1
19.39.0
Most helpful comment
Not clear for me โ why you need to have packed app often. Why you cannot use electron-prebuilt?
In any case โ there is a workaround โ
build.dereferenceadded for you. Disable asar:add this to your
build. Next version will be published soon. Is it suitable for you?This issue in any case should be fixed before, right?