Skip to content

Dependencies are not packaged by electron-builder when using pnpm #6289

Closed

Description

@Ripwords
  • Electron-Builder Version: 22.11.7
  • Node Version: 16.9.1
  • Electron Version: 15.0.0
  • Electron Type (current, beta, nightly): current
  • Target: windows/nsis

I'm having issues trying to use pnpm and electron-builder. I tried multiple times to package the app using basic commands and build configurations from online guides but i would always get dependency related errors after packaging it.

Initially i thought it was my configuration error, but after copying the whole project and used npm instead, everything worked as expected.

From what i could find, it seems that electron-builder can't resolve the dependencies within the .pnpm folder, but i am not 100% certain of this.

pnpm and electron-builder are both great would love to have this fixed

Build config

image

Using pnpm

As shown in the screenshot, semver already exist in node_modules/.pnpm
image

Using npm with same exact build config

Application is built with no errors by electron-builder
image

Activity

  1. mmaietta commented on Sep 26, 2021

    @mmaietta
    Collaborator

    @develar can you please take a look at this when you have a chance?

  2. cangzhang commented on Sep 28, 2021

    @cangzhang

    Run into same problem, the node_modules folder bundled in app.asar does not contain modules installed under .pnpm/, which are symlinks created by pnpm install.

  3. plimeor commented on Oct 11, 2021

    @plimeor

    Any updates?

  4. cah4a commented on Nov 19, 2021

    @cah4a

    Hey guys!
    Do you have any plans to support pnpm?
    It reduces pain for developers that have gigabytes of node_modules placed here and there.
    Would love to use it with electron too.

  5. mmaietta commented on Nov 21, 2021

    @mmaietta
    Collaborator

    I don't have plans to implement the support for pnp. But I'd happily review PRs for it! 🙂

  6. cupcakearmy commented on Jan 21, 2022

    @cupcakearmy

    Same here, would be awesome to have support for it

  7. mmaietta commented on Feb 5, 2022

    @mmaietta
    Collaborator

    Quick test, can someone try setting .npmrc to copy from the global pnpm store for deps?
    https://pnpm.io/npmrc#package-import-method

    package-import-method=copy
    
  8. monsterkodi commented on Feb 6, 2022

    @monsterkodi

    I tried the copy setting. But doesn't seem to make any difference for me.

  9. mmaietta commented on Feb 9, 2022

    @mmaietta
    Collaborator

    @develar really could use your help on this one. Seems to be failing with readDependencyTree in your app-builder project.
    https://github.com/develar/app-builder/blob/c79345743b794ccef41493decafb0b5b2eece505/pkg/node-modules/tree.go#L41

    I've tried other alternatives for reading dependency trees and they aren't viable. I'm not sure how app-builder works, but it seems like it just needs to also search node_modules/.pnpm/node_modules/* for all dependencies

  10. BlackHole1 commented on Feb 17, 2022

    @BlackHole1
    Member
    • set node-linker=hoisted in .npmrc
    • set public-hoist-pattern = * or shamefully-hoist = true in .npmrc

    Choose any of them. The problem will be solved.
    Of course, it would be great if electron-builder could support it.

    Update:

    If your dependencies have multiple versions, it's best to add node-linker = hoisted to avoid having only one version selected during packaging. Refer to the link for more information: pnpm/pnpm#5724 (comment)

  11. CallanBi commented on Feb 24, 2022

    @CallanBi

    Same. Would really love to see it is supported.

  12. the0rem commented on Feb 24, 2022

    @the0rem

    @BlackHole1 thanks for the suggested solution. This is probably an acceptable solution for some however the suggested approach is basically throwing away the benefits of using pnpm in the first place.

    The repo's readme also links to a comment about why yarn should be used however with 129 downvotes and 94 confused emojis it's clearly not backed by the community running into these issues.

    I'm not able to provide a better solution myself but I'd like to point out how much of a hurdle this is for adoption. We're not prepared to relax the reliability of our dependency system that pnpm brings to our monorepo. Changing this for a single package is an unreasonable ask. I hope there is a path forward soon; A fundamental library shouldn't have to compromise it's audience based on a package manager.

  13. stale commented on Apr 28, 2022

    @stale

    Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

  14. cah4a commented on Apr 28, 2022

    @cah4a

    Any progress here?

  15. mmaietta commented on Apr 28, 2022

    @mmaietta
    Collaborator

    Issue is in upstream dependency app-builder (node_modules/app-builder-bin)
    Ref: #6289 (comment)
    You're welcome to file a ticket here https://github.com/develar/app-builder

    Workaround is: #6289 (comment)

  16. locked and limited conversation to collaborators on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions