1
votes

I have a little test electron app named hello world. I am trying to build it and generate a windows installer using electron-builder. My package.json is as follows.

{
  "name": "hello-world",
  "productName": "Hello World",
  "version": "1.0.0",
  "description": "Second attempt at an electron app",
  "main": "main.js",
  "dependencies": {},
  "devDependencies": {
    "electron": "^9.1.1",
    "electron-builder": "^22.8.0"
  },
  "scripts": {
    "start": "electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Computronics",
  "license": "MIT",
  "build": {
    "appId": "com.hello.world",
    "win": {
      "target": "nsis"
    }
  }
}

When I run npm run dist it outputs this.

> [email protected] dist C:\Users\computronics\source\repos\electrontests\hello world
> electron-builder

  • electron-builder  version=22.8.0 os=10.0.18362
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist\builder-effective-config.yaml
  • packaging       platform=win32 arch=x64 electron=9.1.2 appOutDir=dist\win-unpacked
  ⨯ EBUSY: resource busy or locked, rename 'C:\Users\computronics\source\repos\electrontests\hello world\dist\win-unpacked\electron.exe' -> 'C:\Users\computronics\source\repos\electrontests\hello world\dist\win-unpacked\Hello World.exe'  stackTrace=Error: EBUSY: resource busy or locked, rename 'C:\Users\computronics\source\repos\electrontests\hello world\dist\win-unpacked\electron.exe' -> 'C:\Users\computronics\source\repos\electrontests\hello world\dist\win-unpacked\Hello World.exe'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dist: `electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dist 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!     C:\Users\computronics\AppData\Roaming\npm-cache\_logs\2020-07-31T19_00_12_846Z-debug.log

The contents of the log file is as follows:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dist'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predist', 'dist', 'postdist' ]
5 info lifecycle [email protected]~predist: [email protected]
6 info lifecycle [email protected]~dist: [email protected]
7 verbose lifecycle [email protected]~dist: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~dist: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\computronics\source\repos\electrontests\hello world\node_modules\.bin;C:\Program Files\Microsoft VS Code\bin;C:\Windows\System32;C:\Program Files\Git\cmd;C:\Program Files\PowerShell\7-preview\preview;C:\ProgramData\chocolatey\bin;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Users\computronics\.dotnet\tools;
9 verbose lifecycle [email protected]~dist: CWD: C:\Users\computronics\source\repos\electrontests\hello world
10 silly lifecycle [email protected]~dist: Args: [ '/d /s /c', 'electron-builder' ]
11 silly lifecycle [email protected]~dist: Returned: code: 1  signal: null
12 info lifecycle [email protected]~dist: Failed to exec dist script
13 verbose stack Error: [email protected] dist: `electron-builder`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\computronics\source\repos\electrontests\hello world
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dist"
18 verbose node v12.18.3
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] dist: `electron-builder`
22 error Exit status 1
23 error Failed at the [email protected] dist script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

After running npm run dist it creates a working .exe in dist called electron.exe. This launches into the simple hello world app.

I have tried deleting the node_modules folder and reinstalling the dependencies, forcefully cleaning the npm cache and trying different versions of electron-builder.

Other information

OS: Windows 10
npm version: 6.14.6
node version: 12.18.3

Thanks in advance for any help.

1

1 Answers

1
votes

There may be more than one reason for this error. Here are the ways you can get rid out of this error.

Solution 1. Close the browser_broker process

Open up the Windows task manager, find the running process named either browser_broker.exe or Runtime Broker and stop the process. After stopping the process, try building the installer again and it will work.

Solution 2. Kill the Build Tools Process

Open task manager and kill the BuildTolls_Full.exe process. Then Go to C:\Users<User Name>.windows-build-tools and open build-tools-log.txt with a text-editor and append the given and save the file.

Variable: IsInstalled = 1