quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Quasar-CLI Vite fails to build Electron

Open NickNothom opened this issue 2 years ago • 5 comments

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

NickNothom avatar Apr 22 '22 21:04 NickNothom

Have you added Electron mode before trying anything further with quasar mode add electron?

MilosPaunovic avatar Apr 23 '22 08:04 MilosPaunovic

Yes.

NickNothom avatar Apr 25 '22 01:04 NickNothom

same problem here

flesser avatar May 03 '22 14:05 flesser

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

rotu avatar Jun 09 '22 17:06 rotu

check whether electron module installed under the node_modules

quasar mode add electron will install

snowwolfjay avatar Jul 13 '22 03:07 snowwolfjay

@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.

rotu avatar Sep 09 '23 06:09 rotu