I have an Electron application that uses:
React for the frontend
Node + Express backend inside
/ServerA SQLite database stored inside the same
/Serverfolder
During development, everything works correctly.
Running:
npm start
starts Electron, and the server is required inside main.js like this:
require("./Server/index.js");
The React build is loaded from client/build/index.html, and API calls work normally.
Problem
When I package the app using:
npm run dist
The application UI opens, but the backend server does not run, and all API calls from React stay in Pending. The SQLite database is also not found.
So the packaged app runs only the UI, without the server.
Electron Builder also gives warnings like:
asar usage is disabled — this is strongly not recommended
And if I enable asar, the SQLite DB becomes inaccessible.
What I understand so far
The server and
.sqlitefile cannot work properly when bundled insideapp.asar.They need to be unpacked to the real filesystem (e.g.,
resources/server/).The server entry path should change depending on development vs production.
Current build section in package.json
"build": {
"appId": "com.yourcompany.matjari",
"files": [
"main.js",
"Server/**",
"client/build/**"
],
"asar": false
}
Question
What is the correct Electron Builder configuration to:
Include the
/Serverfolder and the SQLite database in the packaged appEnsure the server runs when the app is built (
.exe)Allow the database to be writable and accessible at runtime
Should I use "asar": true and asarUnpack?
Should the database be moved to a different directory such as resources/?
What is the recommended structure for Electron apps that include a backend server and SQLite?
Goal
I want the packaged app (.exe) to:
Start the Express server automatically
Load and use the SQLite database normally
Keep everything inside the installation folder (no external installs required)
Thanks in advance to anyone who has solved this setup before.
resources, packed in asar or not. Your application may use something outside this directory. 2) If you use asar, some API can work with asar internal paths, some cannot.