Search code examples
electronelectron-packager

'Unable to find a valid app' error building electron app using electron-packager


When running my application using npm start, everything works fine. However after building my app using electron-packager and open .exe file, it occurs: 'Unable to find a valid app' , complete description is

error

my packager.json file is:

{
  "name": "electron-roll-tool",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "src/main.js",
  "scripts": {
    "start": "electron .",
    "build": "electron-packager ./src/ electron-roll-tool --win --out ../dist --arch=x64 --version=0.0.1 --overwrite --electron-version=1.8.4"
  },
  "repository": "https://github.com/alex1504/electron-roll-tool",
  "keywords": [
    "Electron"
  ],
  "author": "GitHub",
  "license": "MIT",
  "devDependencies": {
    "electron": "^1.8.4",
    "electron-packager": "^12.0.1"
  },
  "dependencies": {
    "moment": "^2.22.1",
    "xlsx": "^0.12.10"
  }
}

I change the entry point and my project structure is:

project structure

How to solve this problem?


Solution

  • In the package.json, the 'build' command is incorrect. Replace ./src/ with ./ and then use ignore to exclude files and folders.

    Because electron-packager needs the package.json in the src folder to know the main entrance and the dependencies, and also needs the dependencies in src