electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.5k stars 520 forks source link

Cannot run packaged app with tadeious or mssql package #3733

Open vasicvuk opened 1 month ago

vasicvuk commented 1 month ago

Pre-flight checklist

Electron Forge version

7.5.0

Electron version

v32.1.2

Operating system

Windows 11

Last known working Electron Forge version

No response

Issue

I'm encountering issues with packaging my Electron app using Electron Forge, especially regarding including the mssql module. The module works fine in the development environment but fails to load in the packaged version. Additionally, I have tried using the tedious package, and I am running into similar issues.

I started creating the app using vite-typescript template.

The errors vary depending on the configuration:

  1. Without marking mssql as external in vite.config.js: In this case, the development version fails to run, giving the following error: TypeError: Cannot read properties of undefined (reading 'get') at _interopNamespaceDefault
  2. With marking mssql as external in vite.config.js: The development version works, but when I package the app using Electron Forge, I get the following error when trying to start the app: Error: Cannot find module 'mssql'

I also tried disabling asar and contextIsolation but that does not help.

How do you get some of these packages running?

Actual behavior

The app does not run in packaged mode when this packaged are used.

Steps to reproduce

Additional information

No response

jhonpedro commented 1 month ago

Do you have electron rebuild installed?

vasicvuk commented 1 month ago

No i don't have it installed, should I?

jhonpedro commented 1 month ago

try adding it and see if it changes something. I'm also having problem running the packaged version after installing native modules

jhonpedro commented 1 month ago

In my case, unfortunately, I had to change it to the webpack which solved the problem but made my build and start take a lot more time

vasicvuk commented 1 month ago

I added it in package.json like this

    "rebuild": "electron-rebuild -f -w tedious"

and then run:

npm run rebuild
npm run package

When I run it i get the same issue

jhonpedro commented 1 month ago

In my case that _interopNamespaceDefault was being used to do something with the 'process' import. Is it the same for you?

Anyway, it might be worth changing to webpack just to make it work if you are in a hurry. Also it would be good to update the issue with a reproducible repo

vasicvuk commented 1 month ago

Do you know the process of changing to webpack? Thanks

jhonpedro commented 1 month ago

For me I just created a new webpack template and started copying from that template to the original repo. It should be straightforward if you have a little experience with webpack. Besides that, I do not have a series of steps for you to follow, you'll need to change things and test if it works with the electron-forge startt command

4color commented 3 weeks ago

I have also encountered these problems, but I am is sequelize running them all works well. After packaging, running them prompts: Cannot find module 'sequelize'