Skip to content

[PnP] Cannot find the package "electron" #3611

Open
@rtritto

Description

Pre-flight checklist

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

Electron Forge version

7.4.0

Electron version

30.1.0

Vite version

5.0.12

Operating system

Windows 11

Last known working Electron Forge version

No response

Expected behavior

No error

Actual behavior

✔ Checking your system
✔ Locating application
✔ Loading configuration
✔ Preparing native dependencies [0.4s]
✔ Running generateAssets hook

The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
✔ [plugin-vite] Launching dev servers for renderer process code [1s]
✔ [plugin-vite] Compiling main process code [2s]Local:   http://localhost:5173/
  ➜  Network: use --host to expose
vite v5.2.12 building for development...

watching for file changes...
vite v5.2.12 building for development...

watching for file changes...

build started...

build started...
transforming (1) src\preload.ts
transforming (1) src\main.ts
✓ 1 modules transformed.
Generated an empty chunk: "preload".
✓ 1 modules transformed.
rendering chunks (1)...
rendering chunks (1)...
computing gzip size (0)...
computing gzip size (1)...
.vite/build/preload.mjs  0.05 kB │ gzip: 0.07 kB │ map: 0.09 kB
built in 85ms.
computing gzip size (0)...
computing gzip size (1)...
.vite/build/main.js  0.90 kB │ gzip: 0.47 kB │ map: 2.53 kB
built in 88ms.

An unhandled rejection has occurred inside Forge:
Error: Cannot find the package "electron". Perhaps you need to run "yarn install" in "C:\<PROJECT_PATH>"?
at getElectronPackageJSONPath (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-utils-npm-7.4.0-881d5c9e73-10c0.zip\node_modules\@electron-forge\core-utils\src\electron-version.ts:69:11)
    at async getElectronModulePath (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-utils-npm-7.4.0-881d5c9e73-10c0.zip\node_modules\@electron-forge\core-utils\src\electron-version.ts:82:27)
    at async locateElectronExecutable (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-npm-7.4.0-4c33fc0cff-10c0.zip\node_modules\@electron-forge\core\src\util\electron-executable.ts:9:50)
    at async forgeSpawn (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-npm-7.4.0-4c33fc0cff-10c0.zip\node_modules\@electron-forge\core\src\api\start.ts:157:28)
    at async forgeSpawnWrapper (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-npm-7.4.0-4c33fc0cff-10c0.zip\node_modules\@electron-forge\core\src\api\start.ts:200:23)
    at async C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-core-npm-7.4.0-4c33fc0cff-10c0.zip\node_modules\@electron-forge\core\src\api\start.ts:235:21       
    at async C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-tracer-npm-7.4.0-9f71f99d40-10c0.zip\node_modules\@electron-forge\tracer\src\index.ts:51:14        
    at async C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\@electron-forge-cli-npm-7.4.0-bdb0634abf-10c0.zip\node_modules\@electron-forge\cli\src\electron-forge-start.ts:61:1

Steps to reproduce

Additional information

With nodeLinker: node-modules (instead of nodeLinker: pnp) it works.

The error "Cannot find the package "electron"" imply that forge.config.cts file isn't found or is empty.

Related #3209 #3502 #3572 #3582 yarnpkg/berry#1020

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