forge icon indicating copy to clipboard operation
forge copied to clipboard

Support pnpm

Open mika76 opened this issue 3 years ago β€’ 29 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

Using pnpm does not seem to work with electron-forge. An error is thrown when executing pnpx electron-forge import and I do not see any mention of pnpm in the repository and docs.

It would be nice if it worked as pnpm is becoming more and more popular.

Proposed solution

Allow pnpm to work and show working in docs along npm and yarn.

Alternatives considered

npm and yarn

Additional information

No response

mika76 avatar Dec 07 '21 14:12 mika76

any ETA?

renhiyama avatar Feb 04 '22 11:02 renhiyama

Not only import but also the packaging is not working. This is needed to be fixed. It's impossible to use in Monorepos for now :(

RIP21 avatar Mar 21 '22 10:03 RIP21

Try the solution from electron-builder: https://www.electron.build/index.html#note-for-pnpm

My .npmrc file in the project root looks so:

node-linker=hoisted
public-hoist-pattern=*

AlexanderMac avatar Jul 05 '22 08:07 AlexanderMac

Try the solution from electron-builder: https://www.electron.build/index.html#note-for-pnpm

My .npmrc file in the project root looks so:

node-linker=hoisted
public-hoist-pattern=*

Not work.Error info:

    at makeError (C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:22287:17)
    at handlePromise (C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:22858:33)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.handler [as dlx] (C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:199133:7)
    at async C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:206494:21
    at async run (C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:206465:34)
    at async runPnpm (C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:206686:5)
    at async C:\Users\user\AppData\Roaming\npm\node_modules\pnpm\dist\pnpm.cjs:206678:7

Env: OS:Windows 10 Node Version:v16.17.1 pnpm Version:7.13.2

ghost avatar Oct 10 '22 07:10 ghost

I will investigate this issue in the next few days and would prioritize investigating: whether forge can work with pnpm hoist. https://github.com/electron-userland/electron-builder/issues/6289#issuecomment-1042620422

If we need to get forge to actually support pnpm, it's technically possible to do so, it's just going to take a lot of time. I don't want to provide an approximate completion time for this, but I will raise its priority. πŸ˜ƒ

BlackHole1 avatar Nov 04 '22 01:11 BlackHole1

This isn't just a case of supporting pnpm with hoist enabled in this repository, several core dependencies do package traversal. The key ones being:

  • https://github.com/MarshallOfSound/flora-colossus
  • https://github.com/MarshallOfSound/galactus

Galactus depends on flora-colossus so if support is added correctly in the former galactus may Just Workℒ️

Then there's the stuff in this repository, most of which I believe is tied into the yarn-or-npm helper and routed into various helpers throughout the codebase

MarshallOfSound avatar Nov 04 '22 07:11 MarshallOfSound

There's two aspects for pnpm support.

  1. Getting electron forge CLI working with it
  2. Getting electron packager working with it

Sounds like (1) can be resolved if flora-colossus is fixed, can you confirm @MarshallOfSound? Could there be an alternate library we can move to that uses the standard node resolution algorithm (as that should just work, no?).

For (2) - that's more tricky but considering it doesn't even support npm workspaces by default we have more problems. I'd say considering it has a workaround (implementing your own packageAfterCopy with prune: false) you could do the same for pnpm.

Is there any appetite from the core Electron team to look at both pnpm + workspace (for any package manger) support?

itsdouges avatar May 03 '23 07:05 itsdouges

I think @BlackHole1 (who is also a pnpm maintainer) was investigating this issue. Not sure where we ended up!

erickzhao avatar May 03 '23 19:05 erickzhao

Thank you for the reminder, @erickzhao! I apologize for delaying this task πŸ™‡β€β™‚οΈ. Recently, I've been putting my energy into entrepreneurship-related matters and haven't had any extra time to investigate this task, leading me to forget about it 🫨. I will complete my current work as soon as possible to have additional time to conduct the investigation.

BlackHole1 avatar May 04 '23 03:05 BlackHole1

what is missing here?

sibelius avatar Sep 18 '23 13:09 sibelius

We currently have an open PR attached to this issue @sibelius! If you have any input to give as a pnpm user, would be appreciated.

erickzhao avatar Sep 18 '23 18:09 erickzhao

@erickzhao Which PR is it? What needs to be done still on it?

Everspace avatar Nov 09 '23 10:11 Everspace

@erickzhao Which PR is it? What needs to be done still on it?

I assume this one? Although it seems the initial author randomly closed it? https://github.com/electron/forge/pull/3351

cc @erickzhao

GitMurf avatar Nov 09 '23 23:11 GitMurf

Is it possible to modify some settings to prevent electron-forge from bundling dependencies, and instead manually bundle dependencies using esbuild or webpack, thereby avoiding dependence on any packages in node_modules? I think this way can bypass the problem of electron-forge being unable to handle pnpm workspace dependencies.

LZQCN avatar Nov 14 '23 06:11 LZQCN

@LZQCN You can temporarily bypass this issue by configuring pnpm. https://github.com/electron-userland/electron-builder/issues/6289#issuecomment-1042620422

BlackHole1 avatar Nov 14 '23 08:11 BlackHole1

Is it possible to modify some settings to prevent electron-forge from bundling dependencies, and instead manually bundle dependencies using esbuild or webpack, thereby avoiding dependence on any packages in node_modules? I think this way can bypass the problem of electron-forge being unable to handle pnpm workspace dependencies.

I did it. see the monorepos project ai-zen/live2d-copilot.

I use esbuild to bundle dependencies, and avoided the electron-packager copying node_modules by using the following settings:

module.exports = {
  packagerConfig: {
    prune: false,
    ignore: [/node_modules/],
  },
}

LZQCN avatar Nov 14 '23 20:11 LZQCN

πŸ‘€

toFrankie avatar Dec 23 '23 07:12 toFrankie

I use pnpm to install vue and other deps. Too many deps in node_module result npm install electron-squirrel-startup to take 4 hours. (Yes, 4 hours. And I don't really need squirrel)

edit: Changing line 66 in file node_modules\.pnpm\@[email protected]\node_modules\yarn-or-npm to return hasYarn() ? 'yarn' : 'pnpm'; (yes, replace npm to pnpm) will solve this issue.

pnpm just took 6 seconds.

SaigyoujiYuyuko233 avatar Jan 24 '24 14:01 SaigyoujiYuyuko233

Too many deps in node_module result npm install electron-squirrel-startup to take 4 hours.

When I pnpx Electron Forge CLI to init a project scaffold, it uses Yarn 1 to install dependencies unfinished in hours.

So I build an Electron scaffold with PNPM 9: idea2app/Electron-Parcel-PNPM.tsx#1

TechQuery avatar Apr 23 '24 18:04 TechQuery

Any news?

yuyuko233 avatar May 21 '24 03:05 yuyuko233

I think #3574 is the candidate PR moving forward but it will require a thorough review and I think is currently blocked on failing CI. Please follow along there for progress!

Since most maintainers are not PNPM users, we want to be careful with our approach to merging the code. In particular, Electron's approach to packaging applications assumes that node_modules are stored on disk in the traditional npm format, and things might break in subtle ways when using PNPM's symlink model.

Thanks for your patience, everyone. πŸ™‡

erickzhao avatar May 21 '24 18:05 erickzhao