Skip to content

Proposal to Enhance Electron Forge's pnpm Documentation for a Smoother User Experience #240

@youaresoyoung

Description

@youaresoyoung

Hello team,

I'm writing to propose a small but impactful update to the Electron Forge documentation, specifically for users who prefer to use pnpm.

Currently, the official "Getting Started" guide suggests adding node-linker=hoisted to the .npmrc file to address installation issues with pnpm. While this is a great step, I've noticed that it doesn't fully resolve the problem for everyone. Users still frequently encounter the Error: Electron failed to install correctly message.

The root cause seems to be that pnpm's default behavior can prevent Electron's essential postinstall script (install.js) from running properly. After some investigation, I've found that adding an additional configuration to package.json can reliably fix this issue.

The Proposed Solution
I suggest we update the guide to recommend adding the onlyBuiltDependencies field for Electron within the pnpm configuration in package.json.

Here’s how the package.json file would look:

{
  "name": "my-electron-app",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  // ... 
  "pnpm": {
    "onlyBuiltDependencies": [
      "electron"
    ]
  }
}

This configuration explicitly tells pnpm to treat the electron package as a build dependency, ensuring its postinstall script executes as intended. By including this, we can prevent the installation error and provide a more seamless experience for all pnpm users.

Why this is a good idea

  • Improved User Experience: This simple addition would save new users from getting stuck right at the beginning of their Electron development journey.
  • Reduced Support Requests: Fewer users will need to open issues or seek help for this common installation problem.
  • More Robust Documentation: Our official guide will become even more comprehensive and accurate.

I believe this small change would be a significant help to the community. Please let me know if you have any questions.

Thank you for your time and consideration!


Error message
Image

After
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions