Search code examples
javascriptnode.jsnpmelectron

Build issue in electron application


I have built a simple app using electron and it works fine when you launch with npm start. After I try to deploy my application, I get the following error.

WARNING: --asar does not take any arguments, it only has
sub-properties (see --help) Packaging app for platform win32 ia32
using electron v4.1.3 WARNING: Found 'electron' but not as a
devDependency, pruning anyway rcedit.exe failed with exit code 1.
Reserved header is not 0 or image type is not icon for 'a' Fatal
error: Unable to set icon npm ERR! code ELIFECYCLE npm ERR! errno 1
npm ERR! [email protected] package-win: electron-packager .
electron-tutorial-app --overwrite --asar=true --platform=win32
--arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="ShoppingList" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] package-win script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.`

I already tried npm cache clean --force and installed node modules again by npm install but it didn't work in my case. Can anyone please help me with this?

package.json

{
  "name": "shoppinglist",
  "version": "1.0.0",
  "description": "Electron shoppinglist desktop app",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
    "package-win": "electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Shopping List\"",
    "package-linux" : "electron-packager . --overwrite --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds"
  },
  "license": "ISC",
  "dependencies": {
    "electron": "^1.7.6"
  },
  "devDependencies": {
    "electron-packager": "^9.0.1"
  }
}

Solution

  • This can be happen for some reason your cache gets corrupted with some conflicting versions of different dependencies but in your case, you have already run npm cache clean and reinstalled all the node modules.

    Please check folder paths that you have given to the package.json. This might fix your problem.