最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Build issue in electron application - Stack Overflow

programmeradmin1浏览0评论

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"
  }
}

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"
  }
}
Share Improve this question edited Oct 2, 2024 at 18:57 Boshra Jaber 1,1596 gold badges17 silver badges33 bronze badges asked Jun 1, 2019 at 6:12 Steave JonesSteave Jones 1741 silver badge8 bronze badges 2
  • 2 Your production name is different from package.json when pare with error message.. – Aravinda Meewalaarachchi Commented Jun 1, 2019 at 6:16
  • yes...i just change the names frequently..because i thought it might be the spaces between the application name. – Steave Jones Commented Jun 1, 2019 at 6:18
Add a ment  | 

2 Answers 2

Reset to default 3

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.

I have also faced this kind of problem. I have move the electron dependency from dependencies to devDependencies in order to solve the problem.It works for me.

发布评论

评论列表(0)

  1. 暂无评论