electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box

Home Page:https://www.electron.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERR_ELECTRON_BUILDER_CANNOT_EXECUTE

MisterOryon opened this issue · comments

I come to you because after several days of research I did not manage to correct this problem, when i try to create an nsis installer.
you will find attached my json file is the error.
if anyone has an answer to my problem please help me please.

node: v12.18.2
npm: 6.14.5

{
"name": "electron-quick-start",
"version": "2.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"repository": {
"type": "git",
"url": "git+https://github.com"
},
"keywords": [
"Electron"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^9.1.0",
"electron-builder": "^22.0.0"
},
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},
"build": {
"appId": "yourappid",
"win": {
"target": "NSIS"
}
}
}

electron-builder version=22.7.0 os=10.0.19041
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist\builder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=9.1.0 appOutDir=dist\win-unpacked
• default Electron icon is used reason=application icon is not set
• building target=nsis file=dist\electron-quick-start Setup 1.0.0.exe archs=x64 oneClick=true perMachine=false
⨯ C:\Users\C******_M*******\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Output:

Have the same issue here, I need to downgrade to 21.2.0

even with electron-builder version = 21.2.0 the problem persists

Error: C:\Users\M******_C******\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\Bin\makensis.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
at ChildProcess. (H:\SaveLane\node_modules\builder-util\src\util.ts:239:14)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

commented

I had the same issue, I moved my app folder to the root of my hard-drive, and it worked. Electron-builder does not seem to be supporting non-ASCII characters in the path of an app.

unfortunately the problem still persists.

commented

@Eole7 Care to elaborate your solution? I am running into the same issue, not very helpful for my CI.

commented

@Eole7 Care to elaborate your solution? I am running into the same issue, not very helpful for my CI.

Well, if you're running the same issue on your CI, my solution might not help you, as I don't have this issue on my CI. Though, the issue I have on local is that when I add the LICENSE key (but from what I've read on other issues, it could be for other reasons) to my NSIS build parameters and that the path of my app contains non-ASCII characters, I get the above error. I moved my app folder to the root directory of my drive and the build was successful.

I had the same problem but only when trying to brand our product with electron-builder in a linux Debian Buster docker container

The solution that we ended up needing is install wine and wine32 for i386 arch

node: v10.15.3
npm: 6.4.1
electron-builder: 22.8.0

we simple added these commands to our Dockerfile:

 + dpkg --add-architecture i386 && \
    apt-get update && \
    apt-get install <LONG_LIST_OF_PACKAGES_WE_NEED> && \
+  apt-get install wine wine32

The part about needing the wine framework is also detailed in the official docs

This error may also appear when you're trying to build the app while some electron process is running (e.g. after improperly closing the dev server).

Open your task manager and make sure you don't have any running electron processes.

Same here. Above comments are looking not related to my case. I don't know what is wrong.

Solved:
in my case svg app icon did the issue:

"build": {
        "compression": "store",
        "asar": "true",
        "win": {
            "target": "portable",
            "icon": "./html/img/logo.svg",
            "files": ["**/*", "!html/measurements/*"]
        },
        "directories": {
            "app": "."
        }
    }

Under Linux it cannot be even jpg as i did for windows. It has to be png.

same here, issue was missing icon key in build.linux

Yeah, if you look further down the output there should be a more descriptive error. Mine was

Error while loading icon from "C:\...\resources\uninstallerIcon.ico": invalid icon file

I was able to fix it by opening the image in GIMP and re-saving it.

Same for me, wrong icon path. Got to say electron-builder error reporting is quite awful.

commented

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Still relevant. A missing icon shouldn't produce an unrelated "ERR_ELECTRON_BUILDER_CANNOT_EXECUTE" which is impossible to debug.

On GitHub actions I am getting the following error:

electron-builder install-app-deps

  • electron-builder  version=22.9.1
  • loaded configuration  file=package.json ("build" field)
  ⨯ node_modules.Dependency.Dependencies: ReadMapCB: expect { or n, but found [, error found in #10 byte of ...|ncies" : [],
	"main|..., bigger context ...|/garycourt/JSV.git"
		}
	],
	"dependencies" : [],
	"main" : "lib/jsv.js",
	"keywords" : ["json"|...
Error reading package.json: /home/runner/work/arc-electron/arc-electron/node_modules/JSV/package.json  
  ⨯ /home/runner/work/arc-electron/arc-electron/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE  stackTrace=
                                                                                                                                                           Error: /home/runner/work/arc-electron/arc-electron/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
                                                                                                                                                               at ChildProcess.<anonymous> (/home/runner/work/arc-electron/arc-electron/node_modules/builder-util/src/util.ts:243:14)
                                                                                                                                                               at Object.onceWrapper (events.js:422:26)
                                                                                                                                                               at ChildProcess.emit (events.js:315:20)
                                                                                                                                                               at maybeClose (internal/child_process.js:1048:16)
                                                                                                                                                               at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

It looks like a file is not being properly read? Not sure why this error is thrown.

getting the same error, no clue what the cause is

@jarrodek please open a separate issue, EB error reporting is certainly bad and your error code is indeed the same, but the issues should probably be triaged separately.

@FrancescoBorzi not sure which error you're referring to. Is it related to icons? GitHub actions? Please elaborate when you have a chance 🙂

@jarrodek please open a separate issue, EB error reporting is certainly bad and your error code is indeed the same, but the issues should probably be triaged separately.

@FrancescoBorzi not sure which error you're referring to. Is it related to icons? GitHub actions? Please elaborate when you have a chance 🙂

I'm getting the same error as the title of this issue report ERR_ELECTRON_BUILDER_CANNOT_EXECUTE when trying to build my app locally.

My app is: https://github.com/azerothcore/Keira3

reproduction steps: clone the repo, npm install then npm run electron:mac (replace mac with windows or linux accordingly).

Do I need to open a separate issue for that?

I ran into this error as well. Turned out that it didn't like that I had nvm installed (which had somehow caused a weird state where my global npm was missing and I'd needed to install it with yarn). Removing nvm and reinstalling node fixed it for me.

For me the issue was the high resolution of the icns file for the mac icon (1024x1024), and not having specified an icon for the linux build. For the linux version I added a 512x512.png and added it to the linux config, that solved the issue for me.

I had this trouble today.
I used the below command for packaging app in package.json

"deploy:win32": npx electron-builder --config ./build/scripts/win32/build-win32.yml

After some tries, I've got the fact I was using the global npm's electron-builder, so I changed the command like below :

"deploy:win32": "./node_modules/.bin/electron-builder --config ./build/scripts/win32/build-win32.yml",

It works fine now anyway.

For me, the cause was using a monorepo in which the package name was @whatever/subrepo on package.json.

For the linux build, the executable name is taken from there. So the fix for me was

linux: {
          executableName: 'simple-name',
        },

For me It was because of the last build process I've terminated with CTRL + C.

This was the error code I was getting.

Error output:
Bad text encoding: uninstaller.nsh:1
!include: error in script: "uninstaller.nsh" on line 1
Error in script "<stdin>" on line 165 -- aborting creation process

The solution is just re-install the electron-builder.

npm uninstall electron-builder -g
npm install electron-builder -g --save-dev
commented

I was having the same problem.
Apparently electron-builder does blind copy without checking if directories in target path exist and doesn't even try to create them, which raises the exception.
I created all the non-existing directories in target path [/resources] so that it can copy and it worked.

For me npm exec electron-builder ... worked inside the package.json scripts

commented

If you run npx electron-builder, electron-builder will mistakenly use npx as a package manager and try to use it to install dependencies.

This problem may caused by the 'installIcon' config in nsis. Delete it to see if it works

image

Solved for me, the issue was that I had a process still using something in the /dist folder. I closed everything and then deleted the dist directory. Running the command again worked first time.

I for myself had this issue when using the name variable inside the appId build-property. Linux and macOS seemed fine with this, but the Windows build was unable to resolve that variable.

{
	"build": {
		"appId": "com.electron.${name}"
	}
}

As it looks like the issue can be caused by a multitude of different configurations, this possibly is not working for anyone of you. Just wanted to leave my solution out there in case someone also uses a variable inside his appId.

I'm getting the same error suddenly. Possibly after upgrading MacOS to 12.5 (Monterey).

node 16.14
electron-builder-squirrel-windows 23.3.3
electron-squirrel-startup 1.0.0
electron 20.0.1
electron-builder 23.3.3

I've tried agreeing to the xcode license as suggested on #4802 and #4629

I tried clearing the nsis cache in ~/Library/Caches/electron-builder/nsis as suggested somewhere.

I tried clearing my /dist folder as suggested above.

But I still get the following error. Any new ideas?

• building        target=nsis file=dist/xxxx Table Setup 1.1.1.exe archs=x64 oneClick=true perMachine=false
  ⨯ /Users/xxxxxxxxxx/Library/Caches/electron-builder/nsis/nsis-3.0.4.1/mac/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=table.xxxx"
Command line defined: "APP_GUID=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "UNINSTALL_APP_KEY=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "PRODUCT_NAME=xxxx Table"
Command line defined: "PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_FILENAME=xxxx"
Command line defined: "APP_DESCRIPTION=xxxx Table"
Command line defined: "VERSION=1.1.1"
Command line defined: "PROJECT_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table"
Command line defined: "BUILD_RESOURCES_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/build"
Command line defined: "APP_PACKAGE_NAME=xxxx"
Command line defined: "APP_64=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_NAME=xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_HASH=844D52107205EF7694936B5A36512B3FAC3A0933C7CC23D68A372F79A67E82B057C8093E3AA2FB08F6A3B1E32CA934A3E29DF4B612486642662DF3C009B932F7"
Command line defined: "COMPANY_NAME=Brick Design"
Command line defined: "APP_PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_INSTALLER_STORE_FILE=xxxx-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=xxxx Table"
Command line defined: "UNINSTALL_DISPLAY_NAME=xxxx Table 1.1.1"
Command line defined: "ESTIMATED_SIZE=3087595"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/__uninstaller-nsis-xxxx.exe"
Processing script file: "<stdin>" (UTF8)

Error output:
File: failed creating mmap of "/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Error in macro x64_app_files on macroline 1
Error in macro compute_files_for_current_arch on macroline 7
Error in macro extractEmbeddedAppPackage on macroline 8
Error in macro installApplicationFiles on macroline 79
!include: error in script: "installSection.nsh" on line 63
Error in script "<stdin>" on line 189 -- aborting creation process
  failedTask=build stackTrace=Error: /Users/xxxxxxxxxx/Library/Caches/electron-builder/nsis/nsis-3.0.4.1/mac/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=table.xxxx"
Command line defined: "APP_GUID=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "UNINSTALL_APP_KEY=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "PRODUCT_NAME=xxxx Table"
Command line defined: "PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_FILENAME=xxxx"
Command line defined: "APP_DESCRIPTION=xxxx Table"
Command line defined: "VERSION=1.1.1"
Command line defined: "PROJECT_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table"
Command line defined: "BUILD_RESOURCES_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/build"
Command line defined: "APP_PACKAGE_NAME=xxxx"
Command line defined: "APP_64=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_NAME=xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_HASH=844D52107205EF7694936B5A36512B3FAC3A0933C7CC23D68A372F79A67E82B057C8093E3AA2FB08F6A3B1E32CA934A3E29DF4B612486642662DF3C009B932F7"
Command line defined: "COMPANY_NAME=Brick Design"
Command line defined: "APP_PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_INSTALLER_STORE_FILE=xxxx-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=xxxx Table"
Command line defined: "UNINSTALL_DISPLAY_NAME=xxxx Table 1.1.1"
Command line defined: "ESTIMATED_SIZE=3087595"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/__uninstaller-nsis-xxxx.exe"
Processing script file: "<stdin>" (UTF8)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Error output:
File: failed creating mmap of "/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Error in macro x64_app_files on macroline 1
Error in macro compute_files_for_current_arch on macroline 7
Error in macro extractEmbeddedAppPackage on macroline 8
Error in macro installApplicationFiles on macroline 79
!include: error in script: "installSection.nsh" on line 63
Error in script "<stdin>" on line 189 -- aborting creation process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               at ChildProcess.<anonymous> (/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/node_modules/builder-util/src/util.ts:250:14)
    at Object.onceWrapper (node:events:640:26)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

I'm getting the same error suddenly. Possibly after upgrading MacOS to 12.5 (Monterey).

node 16.14 electron-builder-squirrel-windows 23.3.3 electron-squirrel-startup 1.0.0 electron 20.0.1 electron-builder 23.3.3

I've tried agreeing to the xcode license as suggested on #4802 and #4629

I tried clearing the nsis cache in ~/Library/Caches/electron-builder/nsis as suggested somewhere.

I tried clearing my /dist folder as suggested above.

But I still get the following error. Any new ideas?

• building        target=nsis file=dist/xxxx Table Setup 1.1.1.exe archs=x64 oneClick=true perMachine=false
  ⨯ /Users/xxxxxxxxxx/Library/Caches/electron-builder/nsis/nsis-3.0.4.1/mac/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=table.xxxx"
Command line defined: "APP_GUID=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "UNINSTALL_APP_KEY=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "PRODUCT_NAME=xxxx Table"
Command line defined: "PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_FILENAME=xxxx"
Command line defined: "APP_DESCRIPTION=xxxx Table"
Command line defined: "VERSION=1.1.1"
Command line defined: "PROJECT_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table"
Command line defined: "BUILD_RESOURCES_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/build"
Command line defined: "APP_PACKAGE_NAME=xxxx"
Command line defined: "APP_64=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_NAME=xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_HASH=844D52107205EF7694936B5A36512B3FAC3A0933C7CC23D68A372F79A67E82B057C8093E3AA2FB08F6A3B1E32CA934A3E29DF4B612486642662DF3C009B932F7"
Command line defined: "COMPANY_NAME=Brick Design"
Command line defined: "APP_PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_INSTALLER_STORE_FILE=xxxx-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=xxxx Table"
Command line defined: "UNINSTALL_DISPLAY_NAME=xxxx Table 1.1.1"
Command line defined: "ESTIMATED_SIZE=3087595"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/__uninstaller-nsis-xxxx.exe"
Processing script file: "<stdin>" (UTF8)

Error output:
File: failed creating mmap of "/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Error in macro x64_app_files on macroline 1
Error in macro compute_files_for_current_arch on macroline 7
Error in macro extractEmbeddedAppPackage on macroline 8
Error in macro installApplicationFiles on macroline 79
!include: error in script: "installSection.nsh" on line 63
Error in script "<stdin>" on line 189 -- aborting creation process
  failedTask=build stackTrace=Error: /Users/xxxxxxxxxx/Library/Caches/electron-builder/nsis/nsis-3.0.4.1/mac/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=table.xxxx"
Command line defined: "APP_GUID=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "UNINSTALL_APP_KEY=f2485344-d3b0-5398-802d-f91fe2f8b993"
Command line defined: "PRODUCT_NAME=xxxx Table"
Command line defined: "PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_FILENAME=xxxx"
Command line defined: "APP_DESCRIPTION=xxxx Table"
Command line defined: "VERSION=1.1.1"
Command line defined: "PROJECT_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table"
Command line defined: "BUILD_RESOURCES_DIR=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/build"
Command line defined: "APP_PACKAGE_NAME=xxxx"
Command line defined: "APP_64=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_NAME=xxxx-1.1.1-x64.nsis.7z"
Command line defined: "APP_64_HASH=844D52107205EF7694936B5A36512B3FAC3A0933C7CC23D68A372F79A67E82B057C8093E3AA2FB08F6A3B1E32CA934A3E29DF4B612486642662DF3C009B932F7"
Command line defined: "COMPANY_NAME=Brick Design"
Command line defined: "APP_PRODUCT_FILENAME=xxxx Table"
Command line defined: "APP_INSTALLER_STORE_FILE=xxxx-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=xxxx Table"
Command line defined: "UNINSTALL_DISPLAY_NAME=xxxx Table 1.1.1"
Command line defined: "ESTIMATED_SIZE=3087595"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/__uninstaller-nsis-xxxx.exe"
Processing script file: "<stdin>" (UTF8)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Error output:
File: failed creating mmap of "/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/dist/xxxx-1.1.1-x64.nsis.7z"
Error in macro x64_app_files on macroline 1
Error in macro compute_files_for_current_arch on macroline 7
Error in macro extractEmbeddedAppPackage on macroline 8
Error in macro installApplicationFiles on macroline 79
!include: error in script: "installSection.nsh" on line 63
Error in script "<stdin>" on line 189 -- aborting creation process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               at ChildProcess.<anonymous> (/Users/xxxxxxxxxx/Documents/xxxx/Table/xxxx-table/node_modules/builder-util/src/util.ts:250:14)
    at Object.onceWrapper (node:events:640:26)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

I know it sounds dumb, but did you try deleting the dist folder entirely? I get this error every time the dist folder isn't deleted. I'm also building on windows so I'm not sure if this will help you.

I started having this issue upgrading from yarn 1 to yarn 3, however, the exception I'm getting is very generic making it very difficult to understand what exactly is going wrong.

Log from my CI

webpack compiled with 1 warning
  • electron-builder  version=23.4.0 os=10.0.17763
  • artifacts will be published if draft release exists  reason=CI detected
  • loaded configuration  file=package.json ("build" field)
  • installing production dependencies  platform=win32 arch=ia32 appDir=C:\gitlab-runner\builds\bCi-4WEZ\0\xxx\gui\dist\www
  ⨯ C:\Windows\TEMP\xfs-65f3230e\yarn process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
➤ YN0000: ┌ Resolution step
Resolution step
00:00
➤ YN0000: └ Completed
➤ YN0000: ┌ Post-resolution validation
Post-resolution validation
00:00
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 0s 17ms
  failedTask=build stackTrace=Error: C:\Windows\TEMP\xfs-65f3230e\yarn process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
➤ YN0000: ┌ Resolution step
Resolution step
00:00
➤ YN0000: └ Completed
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ➤ YN0000: ┌ Post-resolution validation
Post-resolution validation
00:00
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 0s 17ms
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  at ChildProcess.<anonymous> (C:\gitlab-runner\builds\bCi-4WEZ\0\xxx\gui\node_modules\builder-util\src\util.ts:250:14)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.cp.emit (C:\gitlab-runner\builds\bCi-4WEZ\0\xxx\gui\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1093:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

@PerfectionVR can you try running with DEBUG=electron-builder env var? That'll hopefully show what the cmd being executed is so you can try running it via cmd line separately

@mmaietta

  • electron-builder  version=23.5.1 os=10.0.19044
  • loaded configuration  file=package.json ("build" field)
  • effective config  config=directories:
  output: ./dist/app
  buildResources: build
  app: ./dist/www
appId: com.HELLOWORLD.app
copyright: ${author} All rights reserved.
mac:
  category: com.HELLOWORLD.app
extraResources:
  - filter:
      - ./icons/**/*
icon: ./icons/HELLOWORLD.ico
files: []

  • two package.json structure is used  devPackageFile=C:\Users\XXX\Documents\gui\package.json appPackageFile=C:\Users\XXX\Documents\gui\dist\www\package.json
  • writing effective config  file=dist\app\builder-effective-config.yaml
  • installing production dependencies  platform=win32 arch=ia32 appDir=C:\Users\XXX\Documents\gui\dist\www
  • spawning        command=C:\Users\XXX\AppData\Local\Temp\xfs-5320f62d\yarn install cwd=C:\Users\XXX\Documents\gui\dist\www
Usage Error: The nearest package directory (C:\Users\XXX\Documents\gui\dist\www) doesn't seem to be part of the project declared in C:\Users\XXX\Documents\gui.

- If C:\Users\XXX\Documents\gui isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If C:\Users\XXX\Documents\gui is intended to be a project, it might be that you forgot to list dist/www in its workspace configuration.
- Finally, if C:\Users\XXX\Documents\gui is fine and you intend dist/www to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]
  • exited          command=yarn code=1 pid=14440
  ⨯ C:\Users\XXX\AppData\Local\Temp\xfs-5320f62d\yarn process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1  failedTask=build stackTrace=Error: C:\Users\XXX\AppData\Local\Temp\xfs-5320f62d\yarn process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
    at ChildProcess.<anonymous> (C:\Users\XXX\Documents\gui\node_modules\builder-util\src\util.ts:250:14)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.cp.emit (C:\Users\XXX\Documents\gui\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1093:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

It appears that electron-builder only supports yarn 1 as it is now. But you can't use both yarn 1 and yarn 2 in one project like this...

Yarn 2 is supported from what I understand, just monorepos don't work IIRC? It's been a hot minute since I worked in this category, but here's the code that checks for yarn 2

function checkYarnBerry() {
const npmUserAgent = process.env["npm_config_user_agent"] || ""
const regex = /yarn\/(\d+)\./gm
const yarnVersionMatch = regex.exec(npmUserAgent)
const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0)
return yarnMajorVersion >= 2
}

In my case: docker witch node, java, angular and electron this works - I left full dockerfile

FROM node:16.15.0

WORKDIR /work
COPY package.json .

RUN apt update
RUN apt-get -y install zip unzip

# node_modules witch angular and electron
RUN npm install -g n @angular/cli electron electron-builder

# JAVA
RUN apt-get -y install default-jre
RUN apt install openjdk-11-jre-headless 

# Wine (Wine32)
RUN apt install -y software-properties-common
RUN dpkg --add-architecture i386
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN add-apt-repository 'deb https://dl.winehq.org/wine-builds/debian/ buster main'
RUN apt update
RUN apt -y install --install-recommends winehq-stable

EXPOSE 3002

Yarn 2 is supported from what I understand, just monorepos don't work IIRC? It's been a hot minute since I worked in this category, but here's the code that checks for yarn 2

function checkYarnBerry() {
const npmUserAgent = process.env["npm_config_user_agent"] || ""
const regex = /yarn\/(\d+)\./gm
const yarnVersionMatch = regex.exec(npmUserAgent)
const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0)
return yarnMajorVersion >= 2
}

The challenge/issue here is that the electron-builder has some functionality for which we use the dual package.json method. However, as soon as you use this method, yarn stumbles and can cause this error. I suspect others are also using a dual package.json method.

Refer: https://www.electron.build/tutorials/two-package-structure

Hi, everyone:
I have a problem with electron builds, and when I run on my linux server, I always successfully use user "root" or user "xxy". But I created a CI with jenkins and connected it to user xxy, which prints this error message. I am sure my user 'xxy' has access because I can set up success when I log in to user 'xxy'.

`> xxy-app@3.0.2 dist:win

electron-builder --win --ia32

• electron-builder version=23.6.0 os=3.10.0-1160.76.1.el7.x86_64
• artifacts will be published if draft release exists reason=CI detected
• loaded configuration file=/root/code/electron-builder.yml
• "electron-squirrel-startup" dependency is not required for NSIS
• packaging platform=win32 arch=ia32 electron=20.3.12 appOutDir=build/win-ia32-unpacked
• building target=nsis file=build/xxyapp_windows_3.0.2.exe archs=ia32 oneClick=false perMachine=true
⨯ /home/xxy/.cache/electron-builder/nsis/nsis-3.0.4.1/linux/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
84
Output:
FATAL: main argv conversion failed!
failedTask=build stackTrace=Error: /home/xxy/.cache/electron-builder/nsis/nsis-3.0.4.1/linux/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
84
Output:
FATAL: main argv conversion failed!
at ChildProcess. (/root/code/node_modules/builder-util/src/util.ts:250:14)
at Object.onceWrapper (node:events:640:26)
at ChildProcess.emit (node:events:520:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)`

Hi, everyone: I have a problem with electron builds, and when I run on my linux server, I always successfully use user "root" or user "xxy". But I created a CI with jenkins and connected it to user xxy, which prints this error message. I am sure my user 'xxy' has access because I can set up success when I log in to user 'xxy'.

`> xxy-app@3.0.2 dist:win

electron-builder --win --ia32

• electron-builder version=23.6.0 os=3.10.0-1160.76.1.el7.x86_64 • artifacts will be published if draft release exists reason=CI detected • loaded configuration file=/root/code/electron-builder.yml • "electron-squirrel-startup" dependency is not required for NSIS • packaging platform=win32 arch=ia32 electron=20.3.12 appOutDir=build/win-ia32-unpacked • building target=nsis file=build/xxyapp_windows_3.0.2.exe archs=ia32 oneClick=false perMachine=true ⨯ /home/xxy/.cache/electron-builder/nsis/nsis-3.0.4.1/linux/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 84 Output: FATAL: main argv conversion failed! failedTask=build stackTrace=Error: /home/xxy/.cache/electron-builder/nsis/nsis-3.0.4.1/linux/makensis process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 84 Output: FATAL: main argv conversion failed! at ChildProcess. (/root/code/node_modules/builder-util/src/util.ts:250:14) at Object.onceWrapper (node:events:640:26) at ChildProcess.emit (node:events:520:28) at maybeClose (node:internal/child_process:1092:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)`

My Jenkins configuration commands are as follows:

stage('compile') { steps { echo 'compile' sh encoding: 'UTF-8', script:'export TZ=\'Asia/Shanghai\'; export LC_ALL=en_US.UTF-8; export PATH=${PATH}; pwd; cd /root/code; rm -rf ./dist/* ./build/* && npm run build && npm run dist:win' } }

i my case, don't use npx npx electron-builder --mac --x64 use electron-builder --mac --x64

I am with this problem: • electron-builder version=24.6.4 os=10.0.19045
• loaded configuration file=package.json ("build" field)
• public/electron.js not found. Please see https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3
• loaded parent configuration preset=react-cra
⨯ Invalid configuration object. electron-builder 24.6.4 has been initialized using a configuration object that does not match the API schema.

  • configuration.directories has an unknown property 'win'. These properties are valid:
    object { app?, buildResources?, output? }
    How to fix:

    1. Open https://www.electron.build/configuration/configuration
    2. Search the option name on the page (or type in into Search to find across the docs).
      * Not found? The option was deprecated or not exists (check spelling).
      * Found? Check that the option in the appropriate place. e.g. "title" only in the "dmg", not in the root.
      failedTask=build stackTrace=ValidationError: Invalid configuration object. electron-builder 24.6.4 has been initialized using a configuration object that does not match the API schema.
  • configuration.directories has an unknown property 'win'. These properties are valid:
    object { app?, buildResources?, output? }
    How to fix:

    1. Open https://www.electron.build/configuration/configuration

    2. Search the option name on the page (or type in into Search to find across the docs).
      * Not found? The option was deprecated or not exists (check spelling).
      * Found? Check that the option in the appropriate place. e.g. "title" only in the "dmg", not in the root.

                                                                                                                                                                                at validate (C:\Users\Modul\Desktop\Versoes\Versao 1.0\client\node_modules\@develar\schema-utils\dist\validate.js:86:11)
      

    at validateConfig (C:\Users\Modul\Desktop\Versoes\Versao 1.0\client\node_modules\app-builder-lib\src\util\config.ts:240:3)
    at Packager._build (C:\Users\Modul\Desktop\Versoes\Versao 1.0\client\node_modules\app-builder-lib\src\packager.ts:342:5)
    at Packager.build (C:\Users\Modul\Desktop\Versoes\Versao 1.0\client\node_modules\app-builder-lib\src\packager.ts:337:12)
    at executeFinally (C:\Users\Modul\Desktop\Versoes\Versao 1.0\client\node_modules\builder-util\src\promise.ts:12:14)

    someone please can help-me

    {
    "name": "sismod",
    "author": "modul",
    "version": "0.1.0",
    "description": "teste",
    "private": true,
    "dependencies": {
    "@fontsource/roboto": "^5.0.8",
    "@material/tabs": "^2.3.0",
    "@mui/material": "^5.14.14",
    "@mui/styled-engine-sc": "^6.0.0-alpha.2",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "auth": "^0.0.9",
    "axios": "^1.5.1",
    "child_process": "^1.0.2",
    "concurrently": "^8.2.2",
    "cross-env": "^7.0.3",
    "express": "^4.18.2",
    "formik": "^2.4.5",
    "net": "^1.0.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-minimal-side-navigation": "^1.9.2",
    "react-native": "^0.72.6",
    "react-router-dom": "^6.17.0",
    "react-scripts": "5.0.1",
    "styled-components": "^6.1.0",
    "vite-tsconfig-paths": "^4.2.1",
    "wait-on": "^7.0.1",
    "web-vitals": "^2.1.4",
    "ws": "^8.14.2"
    },
    "main": "public/main.js",
    "homepage": "./",
    "scripts": {
    "electron": "electron .",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "electron:serve": "concurrently -k "cross-env BROWSER=none npm start" "npm run electron:start"",
    "electron:build": "electron-builder",
    "electron:start": "wait-on tcp:3000 && electron .",
    "pack-win": "electron-builder --win"
    },
    "eslintConfig": {
    "extends": [
    "react-app",
    "react-app/jest"
    ]
    },
    "browserslist": {
    "production": [
    ">0.2%",
    "not dead",
    "not op_mini all"
    ],
    "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version"
    ]
    },
    "devDependencies": {
    "electron": "^27.0.2",
    "electron-builder": "^24.6.4"
    },
    "build": {
    "appId": "com.example.myelectronapp",
    "productName": "My Electron App",
    "directories": {
    "output": "dist",
    "win": {
    "target": "nsis"

    }
    }
    }
    }

@GuilhermeAnselmodeSa your issue is different and also explicitly described in your error message

configuration.directories has an unknown property 'win'. These properties are valid:
object { app?, buildResources?, output? }

Closing this ticket as the posts in here are all different issues for a generic error code when electron-builder "can't execute".

For anyone still battling with this issue make sure that the value of build.appId matches with the name property in your package.json

For example: (package.json file)

{
name: "hello",
build: {
appId: "com.electron.hello"
}
}

Notice how they both have the name "hello". This fixed the issue for me.

I had the same issue, I moved my app folder to the root of my hard-drive, and it worked. Electron-builder does not seem to be supporting non-ASCII characters in the path of an app.

In my case it was my project path being to long.

Moving it closer to the root file system resolved the issue. This seems to be a windows issue of some kind