Skip to content

Treating "electron" as peerDependencies will cause some problems #1

@minikinl

Description

@minikinl

"electron": ">=15.0.0"

env

npm: v10.2.4
node: v20.11.1

Problems

the peer dependencies was not treated as devDependencies, so there is no dev mark in package-lock.json file.

when we use npm ci --only-production command to install production dependencies, the electron package will be installed.

but actually not needed.

"node_modules/electron": {
    "version": "30.0.9",
    "resolved": "https://registry.npmjs.org/electron/-/electron-30.0.9.tgz",
    "integrity": "sha512-ArxgdGHVu3o5uaP+Tqj8cJDvU03R6vrGrOqiMs7JXLnvQHMqXJIIxmFKQAIdJW8VoT3ac3hD21tA7cPO10RLow==",
    "hasInstallScript": true,
    "dev": true, // <-- this line
    "dependencies": {
      "@electron/get": "^2.0.0",
      "@types/node": "^20.9.0",
      "extract-zip": "^2.0.1"
    },
    "bin": {
      "electron": "cli.js"
    },
    "engines": {
      "node": ">= 12.20.55"
    }
  }

How to Fix

Maybe it is more appropriate to put electron in devDependencies or optionalDependencies.

This problem occurs when I try to optimize the electron application size, pacakger will put electron in node_modules, It takes up 242MB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions