Skip to content

fix(desktop): resolve package.json loading error in Electron - #2

Merged
2ue merged 1 commit into
2ue:mainfrom
jimbb:fix/electron-package-json-url
Mar 15, 2026
Merged

fix(desktop): resolve package.json loading error in Electron#2
2ue merged 1 commit into
2ue:mainfrom
jimbb:fix/electron-package-json-url

Conversation

@jimbb

@jimbb jimbb commented Mar 15, 2026

Copy link
Copy Markdown

Problem

Desktop app (v3.3.20) fails to start with error:

TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file

Root Cause

packages/core/src/index.ts uses new URL('../package.json', import.meta.url) which Vite converts to a data URL during bundling, causing readFileSync(new URL('data:...')) to fail.

Solution

  • Replace new URL() with path.join(__dirname, '../../package.json')
  • Add json.stringify: true to vite config to prevent JSON inlining
  • Fix path for asar structure (dist/main → ../../package.json)

Testing

  • Built and tested on Windows 11
  • Desktop app now starts successfully without errors

Fixes the startup crash in v3.3.20

- Replace new URL() with path.join() to avoid Vite data URL conversion
- Fix path to ../../package.json for asar structure
- Add json.stringify config to prevent JSON inlining

Fixes desktop app failing to start with ERR_INVALID_URL_SCHEME
@2ue
2ue merged commit f4cad17 into 2ue:main Mar 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants