LuanRoger / electron-shadcn

:electron: Electron Forge with shadcn-ui (Vite + Typescript)
MIT License
163 stars 27 forks source link

Linux build fails #78

Closed yuripourre closed 2 weeks ago

yuripourre commented 1 month ago

When I try to use npm run package it successfully generates the binary but when I try to execute it, I got the following error.

I am using Fedora 40.

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'electron-squirrel-startup'

Require stack:
- /home/myuser/electron-shadcn/out/electron-shadcn Template-linux-x64/resources/app.asar/.vite/build/main.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
    at s._resolveFilename (node:electron/js2c/browser_init:2:124038)
    at Module._load (node:internal/modules/cjs/loader:1058:27)
    at c._load (node:electron/js2c/node_init:2:17025)
    at Module.require (node:internal/modules/cjs/loader:1318:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/myuser/electron-shadcn/out/electron-shadcn Template-linux-x64/resources/app.asar/.vite/build/main.js:1:62)
    at Module._compile (node:internal/modules/cjs/loader:1484:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1295:32)
yuripourre commented 1 month ago

If I remove the following lines it works!

if (require("electron-squirrel-startup")) {
    app.quit();
}
LuanRoger commented 1 month ago

Hello, thank you for the report.

Unfortunately, I'm not able to reproduce this problem since I'm on Windows 11, but for what seems to be, it's something related to the Squirrel, which is a package to manage the installation and updating a Windows application, so it's make sense to throw error when not running on Windows.

As I said, I can't reproduce and fix the issue, so It'll be very appreciated if you or any other people fix this problem, guarantee that the problem was solved and send a PR.

You can simple check if the program is running on Windows or not using the Node's process.platform variable, as is made for darwin in the same main.ts file.

yuripourre commented 1 month ago

@LuanRoger ok, I can try that! I am very new to Electron.

yuripourre commented 2 weeks ago

Since the line was removed, the project now runs without changes. Thank you!