How can I build linux, macOs and windows Desktop apps with electron. I have the following pipeline:
image: node:14
stages:
- build
variables:
ELECTRON_CACHE: "$CI_PROJECT_DIR/.cache/electron"
ELECTRON_BUILDER_CACHE: "$CI_PROJECT_DIR/.cache/electron-builder"
before_script:
- npm install -g electron-builder
- apt-get update
- apt-get install -y wine
build_macos:
stage: build
script:
- npm install
- npm run build:mac
- electron-builder --mac --x64
artifacts:
paths:
- dist/*.dmg
- dist/*.zip
only:
- main
build_windows:
stage: build
tags:
- windows
script:
- npm install
- apt-get install wine
- npm run build:win
- electron-builder --win --x64
artifacts:
paths:
- dist/*.exe
- dist/*.zip
only:
- main
build_linux:
stage: build
script:
- npm install
- npm run build:linux
- electron-builder --linux --x64
artifacts:
paths:
- dist/*.AppImage
- dist/*.deb
- dist/*.rpm
only:
- main
but I get the following error while building windows:
npm run build:win
> [email protected] build:win /builds/repo/jg-desktop-app
> electron-builder --win
> • electron-builder version=24.13.3 os=5.15.154+
> • artifacts will be published if draft release exists reason=CI detected
> • loaded configuration file=package.json ("build" field)
> • packaging platform=win32 arch=x64 electron=31.3.0 appOutDir=dist/win-unpacked
> • downloading url=https://github.com/electron/electron/releases/download/v31.3.0/electron-v31.3.0-win32-x64.zip size=111 MB parts=4
> • downloaded url=https://github.com/electron/electron/releases/download/v31.3.0/electron-v31.3.0-win32-x64.zip duration=3.075s
> • downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z size=5.6 MB parts=1
> • downloaded url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z duration=426ms
> ⨯ wine is required, please see https://electron.build/multi-platform-build#linux
> ⨯ /builds/repo/jg-desktop-app/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
> Exit code:
> 1 failedTask=build stackTrace=Error: /builds/repo/jg-desktop-app/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
> Exit code:
> 1
> at ChildProcess.<anonymous> (/builds/repo/jg-desktop-app/node_modules/builder-util/src/util.ts:252:14)
> at Object.onceWrapper (events.js:520:26)
> at ChildProcess.emit (events.js:400:28)
> at maybeClose (internal/child_process.js:1088:16)
> at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
> From previous event:
> at processImmediate (internal/timers.js:464:21)
> From previous event:
> at WinPackager.signApp (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/winPackager.ts:384:27)
> at WinPackager.doSignAfterPack (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/platformPackager.ts:336:32)
> at WinPackager.doPack (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/platformPackager.ts:321:7)
> at WinPackager.pack (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/platformPackager.ts:140:5)
> at Packager.doBuild (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/packager.ts:445:9)
> at executeFinally (/builds/repo/jg-desktop-app/node_modules/builder-util/src/promise.ts:12:14)
> at Packager._build (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/packager.ts:379:31)
> at Packager.build (/builds/repo/jg-desktop-app/node_modules/app-builder-lib/src/packager.ts:340:12)
> at executeFinally (/builds/repo/jg-desktop-app/node_modules/builder-util/src/promise.ts:12:14)
> npm ERR! code ELIFECYCLE
> npm ERR! errno 1
> npm ERR! [email protected] build:win: `electron-builder --win`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the [email protected] build:win script.
> npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
> npm ERR! A complete log of this run can be found in:
> npm ERR! /root/.npm/_logs/2024-07-31T06_44_43_537Z-debug.log
> Cleaning up project directory and file based variables 00:00
> ERROR: Job failed: exit code 1`
and for macOS:
$ npm run build:mac
> [email protected] build:mac /builds/repo/jg-desktop-app
> electron-builder --mac
• electron-builder version=24.13.3 os=5.15.154+
• artifacts will be published if draft release exists reason=CI detected
• loaded configuration file=package.json ("build" field)
⨯ Cannot find module 'dmg-license'
Require stack:
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmgLicense.js
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmg.js
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmgUtil.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/macPackager.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/packager.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/index.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/out/builder.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/out/cli/cli.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/cli.js failedTask=build stackTrace=Error: Cannot find module 'dmg-license'
Require stack:
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmgLicense.js
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmg.js
- /builds/repo/jg-desktop-app/node_modules/dmg-builder/out/dmgUtil.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/macPackager.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/packager.js
- /builds/repo/jg-desktop-app/node_modules/app-builder-lib/out/index.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/out/builder.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/out/cli/cli.js
- /builds/repo/jg-desktop-app/node_modules/electron-builder/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:931:15)
at Function.Module._load (internal/modules/cjs/loader.js:774:27)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object.<anonymous> (/builds/repo/jg-desktop-app/node_modules/dmg-builder/src/dmgLicense.ts:7:1)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object.<anonymous> (/builds/repo/jg-desktop-app/node_modules/dmg-builder/src/dmg.ts:13:1)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:mac: `electron-builder --mac`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:mac script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2024-07-31T06_44_37_599Z-debug.log
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1
I want to create an Elektron desktop application for Linux, macOS and Windows. The Linux build package works fine. Can anyone help me?
New contributor
stacki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.