gpt4 book ai didi

electron - Electron 生成器:资源繁忙或锁定。无法创建安装程序

转载 作者:行者123 更新时间:2023-12-03 12:25:23 25 4
gpt4 key购买 nike

我有一个名为hello world的小测试 Electron 应用程序。我正在尝试构建它,并使用electronic-builder生成Windows安装程序。我的package.json如下。

{
"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"
}
}
}
当我运行 npm run dist时,它将输出。
> hello-world@1.0.0 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! hello-world@1.0.0 dist: `electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world@1.0.0 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
日志文件的内容如下:
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 npm@6.14.6
3 info using node@v12.18.3
4 verbose run-script [ 'predist', 'dist', 'postdist' ]
5 info lifecycle hello-world@1.0.0~predist: hello-world@1.0.0
6 info lifecycle hello-world@1.0.0~dist: hello-world@1.0.0
7 verbose lifecycle hello-world@1.0.0~dist: unsafe-perm in lifecycle true
8 verbose lifecycle hello-world@1.0.0~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 hello-world@1.0.0~dist: CWD: C:\Users\computronics\source\repos\electrontests\hello world
10 silly lifecycle hello-world@1.0.0~dist: Args: [ '/d /s /c', 'electron-builder' ]
11 silly lifecycle hello-world@1.0.0~dist: Returned: code: 1 signal: null
12 info lifecycle hello-world@1.0.0~dist: Failed to exec dist script
13 verbose stack Error: hello-world@1.0.0 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 hello-world@1.0.0
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 hello-world@1.0.0 dist: `electron-builder`
22 error Exit status 1
23 error Failed at the hello-world@1.0.0 dist script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
运行 npm run dist后,它将在dist中创建一个名为 electron.exe的工作.exe。这将启动到简单的hello world应用程序中。
我尝试删除node_modules文件夹并重新安装依赖项,强行清理npm缓存,并尝试使用不同版本的 Electron 生成器。
其他资讯
OS: Windows 10
npm version: 6.14.6
node version: 12.18.3
在此先感谢您的帮助。

最佳答案

可能有多个原因导致此错误。这是摆脱该错误的方法。
解决方案1.关闭browser_broker进程
打开Windows任务管理器,找到名为browser_broker.exeRuntime Broker的正在运行的进程,然后停止该进程。停止该过程之后,请尝试再次构建安装程序,它将可以正常运行。
解决方案2.终止构建工具过程
打开任务管理器并杀死BuildTolls_Full.exe进程。然后转到C:\Users <用户名> .windows-build-tools并使用文本编辑器打开build-tools-log.txt并附加给定的内容并保存文件。

Variable: IsInstalled = 1

关于electron - Electron 生成器:资源繁忙或锁定。无法创建安装程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63197873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com