Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with linked npm packages and asar #675

Closed
anri-asaturov opened this issue Aug 17, 2016 · 19 comments · May be fixed by qcif/data-curator#563
Closed

Problem with linked npm packages and asar #675

anri-asaturov opened this issue Aug 17, 2016 · 19 comments · May be fixed by qcif/data-curator#563
Labels

Comments

@anri-asaturov
Copy link

anri-asaturov commented Aug 17, 2016

  • Version: 5.26.0
  • Target: mac

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.

@develar develar added the bug label Aug 19, 2016
@virror
Copy link

virror commented Aug 22, 2016

Would also love to see a fix for this since it worked before in 4.x.

@cwillisf
Copy link
Contributor

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.

@anri-asaturov
Copy link
Author

@cwillisf check this out (link to source inside): electron/asar#85

@develar
Copy link
Member

develar commented Aug 26, 2016

Working on fix.

@develar
Copy link
Member

develar commented Aug 26, 2016

BTW, you should never build production builds using npm linked modules.

@virror
Copy link

virror commented Aug 26, 2016

I know, but its convenient for developing sometimes : )

@anri-asaturov
Copy link
Author

@develar Well, if you bundle everything and keep everything in 'devDependencies' then it's fine.

@develar
Copy link
Member

develar commented Aug 26, 2016

@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.

@anri-asaturov
Copy link
Author

anri-asaturov commented Aug 26, 2016

@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.

@develar
Copy link
Member

develar commented Aug 26, 2016

@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.

@anri-asaturov
Copy link
Author

anri-asaturov commented Aug 26, 2016

@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.

@develar
Copy link
Member

develar commented Aug 26, 2016

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.

@develar develar closed this as completed Aug 26, 2016
@anri-asaturov
Copy link
Author

Any hints on how to potentially fix the 'copy as is' issue with linked packages? I could try to fix it.

@develar
Copy link
Member

develar commented Aug 26, 2016

@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.

@anri-asaturov
Copy link
Author

anri-asaturov commented Aug 26, 2016

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.

develar added a commit to develar/electron-builder that referenced this issue Aug 26, 2016
@develar
Copy link
Member

develar commented Aug 26, 2016

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?

@develar develar removed the backlog label Jan 7, 2017
@develar
Copy link
Member

develar commented Jan 7, 2017

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.

develar added a commit to develar/electron-builder that referenced this issue Jan 8, 2017
develar added a commit to develar/electron-builder that referenced this issue Jan 8, 2017
develar added a commit to develar/electron-builder that referenced this issue Jan 8, 2017
@anaszgh
Copy link

anaszgh commented Oct 19, 2017

I'm still facing the same problem with electron-builder 19.24.1

@develar
Copy link
Member

develar commented Oct 19, 2017

19.39.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants