Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package.json does not exist at ./.vite/package.json #3446

Open
3 tasks done
benbucksch opened this issue Dec 19, 2023 · 2 comments
Open
3 tasks done

package.json does not exist at ./.vite/package.json #3446

benbucksch opened this issue Dec 19, 2023 · 2 comments
Labels
blocked/needs-repro Issues unable to be reproduced by maintainers bug plugin/vite

Comments

@benbucksch
Copy link

benbucksch commented Dec 19, 2023

Pre-flight checklist

  • I have once read some documentation for some project
  • I agree to behave
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.2.0

Electron version

28.0.0

Operating system

Ubuntu

Last known working Electron Forge version

No response

Expected behavior

  • yarn start lauches the app

Actual behavior

$ yarn start
yarn run v1.22.10
$ electron-forge start
✔ Checking your system
✔ Locating application
✔ Loading configuration
✔ Preparing native dependencies: 6 / 6 [0.4s]
✔ Running generateAssets hook
⠙ [plugin-vite] Launching dev servers for renderer process code
◼ [plugin-vite] Compiling main process code
✔ [plugin-vite] Launching dev servers for renderer process code [0.1s]
⠙ [plugin-vite] Compiling main process code
vite v4.5.1 building for development...

watching for file changes...
vite v4.5.1 building for development...

watching for file changes...

build started...

build started...
✔ [plugin-vite] Launching dev servers for renderer process code [0.1s]
⠹ [plugin-vite] Compiling main process code
✔ [plugin-vite] Launching dev servers for renderer process code [0.1s]
✔ [plugin-vite] Launching dev servers for renderer process code [0.1s]
⠏ [plugin-vite] Compiling main process code
✔ [plugin-vite] Launching dev servers for renderer process code [0.1s]
✔ [plugin-vite] Compiling main process code [6s]

App threw an error during load
Error: package.json does not exist at ./.vite/package.json
    at e.find (./.vite/build/main.js:143:2380)
    at /usr/src/mustang/app/electron/.vite/build/main.js:145:179
    at Object.<anonymous> (./.vite/build/main.js:145:253)
    at Module._compile (node:internal/modules/cjs/loader:1271:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at l._load (node:electron/js2c/asar_bundle:2:13642)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: package.json does not exist at ./.vite/package.json
    at e.find (./.vite/build/main.js:143:2380)
    at ./.vite/build/main.js:145:179
    at Object.<anonymous> (./.vite/build/main.js:145:253)
    at Module._compile (node:internal/modules/cjs/loader:1271:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at l._load (node:electron/js2c/asar_bundle:2:13642)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Steps to reproduce

  1. yarn install
  2. yarn start

It does not happen with a minimal electron app. I depend on a library in a monorepo, with package.json dependencies saying foolib: "../foolib" . No idea whether that is the cause or not.

Additional information

Contents of .vite:

  • .vite/
  • .vite/build/
  • .vite/build/locales/
  • .vite/build/locales/en-US.json
  • .vite/build/preload.js
  • .vite/build/main.js (contains compressed JS)

DEBUG run:

$ DEBUG=electron-forge:* yarn start
yarn run v1.22.10
$ electron-forge start
⠋ Checking your system
  electron-forge:check-system checking system, create ~/.skip-forge-system-check✔ Checking your system
[STARTED] Locating application
  electron-forge:project-resolver searching for project in: . +0ms
  electron-forge:project-resolver package.json with forge dependency found in ./package.json +1ms
[SUCCESS] Locating application
[STARTED] Loading configuration
  electron-forge:plugin:vite hooking process events +0ms
[SUCCESS] Loading configuration
[STARTED] Preparing native dependencies
[TITLE] Preparing native dependencies
[TITLE] Preparing native dependencies: 0 / 1
[TITLE] Preparing native dependencies: 1 / 1
[TITLE] Preparing native dependencies: 1 / 2
[TITLE] Preparing native dependencies: 2 / 2
[TITLE] Preparing native dependencies: 2 / 3
[TITLE] Preparing native dependencies: 3 / 3
[TITLE] Preparing native dependencies: 3 / 4
[TITLE] Preparing native dependencies: 4 / 4
[TITLE] Preparing native dependencies: 4 / 5
[TITLE] Preparing native dependencies: 5 / 5
[TITLE] Preparing native dependencies: 5 / 6
[TITLE] Preparing native dependencies: 6 / 6
[SUCCESS] Preparing native dependencies: 6 / 6
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
  electron-forge:plugins plugin: "vite" has taken control of the start command +0ms
[STARTED] [plugin-vite] Launching dev servers for renderer process code
  electron-forge:plugin:vite:viteconfig Config mode: development +0ms
  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
[SUCCESS] [plugin-vite] Launching dev servers for renderer process code
[STARTED] [plugin-vite] Compiling main process code
vite v4.5.1 building for development...

watching for file changes...
vite v4.5.1 building for development...

watching for file changes...

build started...

build started...
✓ 1 modules transformed.
Generated an empty chunk: "preload".
.vite/build/preload.js  0.01 kB │ gzip: 0.03 kB
built in 132ms.
✓ 1606 modules transformed.
.vite/build/main.js  2,990.68 kB │ gzip: 953.60 kB
built in 6534ms.
[SUCCESS] [plugin-vite] Compiling main process code
  electron-forge:start Electron binary path: ./node_modules/electron/dist/electron +0ms
  electron-forge:plugin:vite hooking electron process exit +7s

(and then the stack above)
(In the above pastes, I have replaced the absolute path to the current dir with ..)

@benbucksch
Copy link
Author

Same problem with electron-vite / electron-builder, so most likely not a bug in electron-forge, but in the app.
Unfortunately, the error message is patently unhelpful and blames the build system.

@caoxiemeihao
Copy link
Member

Can you provide a minimal reproduction repo with electron-vite ?
Perhaps the options.baseDir makes sense. 🤔

// Reserved option, may support modification in the future.
// @defaultValue '.vite'
// baseDir?: string;

@erickzhao erickzhao added blocked/needs-repro Issues unable to be reproduced by maintainers plugin/vite labels Feb 1, 2025
@erickzhao erickzhao added the bug label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/needs-repro Issues unable to be reproduced by maintainers bug plugin/vite
Projects
None yet
Development

No branches or pull requests

3 participants