Home>

The Electron application is created and the installer is created.
I was able to output the setup file with Electron builder, but
It will be installed with the Node module omitted.
html, css, and JavaScript are loaded without any problems.

I created it with the following command, but what is missing?

electron-builder .test-win32-x64 --platform = win --arch = x64

How to create and load package.json doesn't work ...

{
  "name": "test",
  "version": "0.1.0",
  "description": "test",
  "main": "server.js",
  "scripts": {
    "test": "echo \" Error: no test specified \ "&&exit 1",
    "dev": "electron ./irohanote",
    "pack: win": "electron-builder ./dist/test-win32-x64 --platform = win --arch = x64"
  },
  "author": "",
  "license": "BSD",
  "dependencies": {
    "electron": "^ 2.0.7",
    "express": "^ 4.16.3",
    "gulp": "^ 3.9.1",
    "jquery": "^ 2.2.4"
  },
  "build": {
      "appId": "com.test.app",
      "win": {
           "target": "nsis",
        "icon": "assets/Icon.ico"
    }
  }
}


The development environment is Windows.

/app/(Electron app)
|-package.json
|-main.js
|-index.html
|-node_modules
|-etc ...
/ assets/(icon file)
|-icon.ico
/ dist/(output packaged file)
/package.json // Npm run pack: win

  • Answer # 1

    Electron may be registered on the dependencies side.

    After deleting and npm i -D electron (or yarn add --dev electron)
    Try running electron-builder.

    My environment is mac, but it was able to run with express included.

    Addendum

    We just added the necessary code and settings for Electron to the project generated by Node.js Express App of IntelliJ IDEA. I built it with the following package.json.

    The execution of the build is yarn packmac.
    An installation file is created under the ./dist folder.

    The build part needs to be changed according to Windows, but it will work.

    {
      "name": "electron-express",
      "version": "0.0.0",
      "private": true,
      "scripts": {
        "start": "node ./bin/www",
        "packmac": "build --mac --x64"
      },
      "dependencies": {
        "cookie-parser": "~ 1.4.3",
        "debug": "~ 2.6.9",
        "express": "~ 4.16.0",
        "http-errors": "~ 1.6.2",
        "morgan": "~ 1.9.0",
        "pug": "2.0.0-beta11"
      },
      "devDependencies": {
        "electron": "^ 2.0.8",
        "electron-builder": "^ 20.28.3"
      },
      "main": "main.js",
      "build": {
        "appId": "com.example",
        "mac": {
          "target": "dmg"
        },
        "directories": {
          "output": "dist"
        }
      }
    }