quasar
quasar copied to clipboard
Quasar-CLI Vite fails to build Electron
What happened?
I started a fresh project with npm init quasar
, accepted all of the defaults (except choosing Vite).
-
quasar dev
works -
quasar build
works -
quasar dev -m electron
works
But quasar build -m electron
crashes, and after that the quasar command is completely broken until I run npm install
again.
App • WAIT • Bundling app with electron-packager...
/home/nick/projects/quasar-project/node_modules/@quasar/app-vite/lib/modes/electron/electron-builder.js:130
electronVersion: getPackageJson('electron').version
^
TypeError: Cannot read properties of undefined (reading 'version')
at /home/nick/projects/quasar-project/node_modules/@quasar/app-vite/lib/modes/electron/electron-builder.js:130:56
at new Promise (<anonymous>)
at /home/nick/projects/quasar-project/node_modules/@quasar/app-vite/lib/modes/electron/electron-builder.js:124:14
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ElectronBuilder.build (/home/nick/projects/quasar-project/node_modules/@quasar/app-vite/lib/modes/electron/electron-builder.js:23:7)
After this, running quasar
gives:
--------------
=> IMPORTANT !
=> Trigger this inside of a Quasar project (and npm/yarn install) for more commands.
--------------
Until I npm install
/ yarn
I injected a few other lines here to test getPackageJson() with other package names, and it isn't able to resolve any of them. It always falls into this catch block.
I get the same results with npm and yarn. I get the same error with builder
instead of packager
except it fails on L132 instead of L130.
What did you expect to happen?
The electron app would be built.
Reproduction URL
https://github.com/NickNothom/quasar-cli-vite-electron-bug
How to reproduce?
-
yarn create quasar
/npm init quasar
- Choose Vite, accept all other defaults
-
cd quasar-project
-
quasar build -m electron
/yarn quasar build -m electron
/npx quasar build -m electron
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite), Electron Mode
Platforms/Browsers
No response
Quasar info output
Operating System Linux(5.4.0-105-generic) - linux/x64
NodeJs 16.13.1
Global packages
NPM 8.1.2
yarn 1.22.15
@quasar/cli 1.3.2
@quasar/icongenie 2.5.1
cordova Not installed
Networking
Host photon-linux
enp5s0 10.0.0.254
ztmjfncnhw 10.144.216.2
Relevant log output
No response
Additional context
No response
Have you added Electron mode before trying anything further with quasar mode add electron
?
Yes.
same problem here
I'm seeing similar problems when using node 16.13.1 that go away when I bump to 16.15.1 via nvm.
Edit: take this with a grain of salt - I'm not able to reliably reproduce the issue
check whether electron module installed under the node_modules
quasar mode add electron will install
@snowwolfjay I think you're right and that electron should have been added to package.json
by quasar build -m electron
.
I'm thinking the root cause was likely fixed by https://github.com/quasarframework/quasar/commit/b7dff677813094654a5da0d02ccef8ecb3b8acd2.