Deploy and distribute Electron + NodeJS + ExpressJS app

Hi everyone,

I’m trying to deploy and distribute around some computers my app. I used NodeJS + ElectronJS + Electron to develop the app and ejs for the views.
I modified my package.json like this:

"name": "electronjs",
"productName": "Tasks",
"version": "1.0.0",
"description": "Aplicacion tareas",
"private": true,
"main": "main.js",
"scripts": {
    "test": "electromon .",
    "start": "electron .",
    "postinstall": "electron-builder install-app-deps",
    "pack": "electron-builder --dir",
    "dist": "electron-builder"
"author": "Ernesto",
"license": "MIT",
"devDependencies": {
    "body-parser": "^1.19.0",
    "ejs": "^3.1.3",
    "electron": "^9.1.1",
    "electron-builder": "^22.7.0",
    "electron-packager": "^15.0.0",
    "electron-winstaller": "^4.0.1",
    "express": "^4.17.1",
    "express-session": "^1.17.1",
    "html-pdf": "^2.2.0",
    "mssql": "^6.2.0"
"dependencies": {
    "date-format": "^3.0.0",
    "easy-pdf-merge": "^0.2.2",
    "electron-alert": "^0.1.6",
    "exceljs": "^4.1.1",
    "jquery": "^3.5.1",
    "pdf-creator-node": "^1.4.1",
    "select2": "^4.0.13"
"build": {
    "appId": "com.ernes.tasks",
    "files": [
    "forceCodeSigning": false,
    "win": {
        "target": {
            "target": "nsis",
            "arch": [
    "nsis": {
        "oneClick": false,
        "perMachine": false,
        "allowToChangeInstallationDirectory": true,
        "menuCategory": "Tasks"

And then I run the following commands on the VSCode console:

  1. npm run pack
    After this command, the folder dist is created and inside this folder another folder named win-unpacked with a .exe file. When I try to execute the .exe file it appears the following error:
    Error: Cannot find module ‘express’
    But It has no sense cuz when I use the npm run start command the app starts without error.
  2. npm run dist
    With this command I create an installer for the app, and if I install the app using the installer, when I try to execute it, the same error persists.

I also want to know if I can solve the error, if I want to distribute around some computers how will NodeJS work in that case? Every app creates a NodeJS server or I have to keep the NodeJS server powered on on my computer?

I don’t know how to solve it and I’m a bit new using electron, so thanks everyone.