electron-vue 打包时遇到'resource busy or locked' 错误

发布于 2022-09-11 18:44:04 字数 5724 浏览 8 评论 0

我的工作用electron-vue开发一个简单的桌面应用,目前开发工作基本快完成了,第一次打包的时候还可以正常打包,也可以正常安装,但是在我发第二次打包的时候却遇到了这样的错误,之后我尝试各种方法也绕不过这个错误,打包失败:

Error: EBUSY: resource busy or locked, unlink 'C:\Users\me\Documents\GitHub\statistic\statistic\build\win-unpacked\resources\app.asar'
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\packager\dirPackager.ts:54:7
    at Generator.next (<anonymous>)
From previous event:
    at unpack (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\packager\dirPackager.js:55:21)
    at unpackElectron (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\packager\dirPackager.ts:27:10)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\platformPackager.ts:164:27
    at Generator.next (<anonymous>)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
From previous event:
    at WinPackager.doPack (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\platformPackager.js:276:11)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\platformPackager.ts:113:16
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.pack (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\platformPackager.js:196:11)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\packager.ts:364:24
    at Generator.next (<anonymous>)
    at xfs.stat (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\fs-extra-p\node_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\graceful-fs\polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:153:5)
From previous event:
    at Packager.doBuild (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\packager.js:432:11)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\packager.ts:308:52
    at Generator.next (<anonymous>)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\graceful-fs\graceful-fs.js:99:16
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\graceful-fs\graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
From previous event:
    at Packager._build (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\packager.js:376:11)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\src\packager.ts:270:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
From previous event:
    at Packager.build (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder-lib\out\packager.js:332:11)
    at C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\src\builder.ts:310:40
    at Generator.next (<anonymous>)
From previous event:
    at _build (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\out\builder.js:61:21)
    at build (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\src\builder.ts:280:10)
    at then (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\src\cli\cli.ts:48:33)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
From previous event:
    at Object.args [as handler] (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\src\cli\cli.ts:48:33)
    at Object.runCommand (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\node_modules\yargs\lib\command.js:235:44)
    at Object.parseArgs [as _parseArgs] (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\node_modules\yargs\yargs.js:1074:24)
    at Object.get [as argv] (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\node_modules\yargs\yargs.js:989:21)
    at Object.<anonymous> (C:\Users\me\Documents\GitHub\statistic\statistic\node_modules\electron-builder\src\cli\cli.ts:42:15)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

我用的打包工具是electron-builder, 最让我疑惑的是我第一次打包成功后,只是做了简单的修改,然后第二次打包就遇到了这个问题,感觉很没有思路。
github地址:https://github.com/zixusir/st...
谢谢!

希望国外的朋友也能支援一下,确实拖了太久啦。。。
my work is developing a desktop app by electron-vue. At present, most developing works have been finished. But after my first successfully package, I come across such above error, which says Error: EBUSY: resource busy or locked, unlink 'C:\Users\me\Documents\GitHub\statistic\statistic\build\win-unpacked\resources\app.asar'
it's my first time to develop a app by electron-vue, so I found few idea about this question.
the github repositoy of this project is https://github.com/zixusir/st...
thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

め七分饶幸 2022-09-18 18:44:04

报这个错的原因是dist文件夹内的文件被其他进程占用, 此时你试图删除这个文件夹的话会报如下这个错误
这个报错相信大家都很熟悉了, 解决办法就是关闭占用这个文件夹的进程,
而我这里会出现这个问题是因为之前在dist文件夹里打开了cmd命令行窗口, 导致进程占用,
关掉后就可以了.
clipboard.png

南巷近海 2022-09-18 18:44:04

是用VS Code开发吗?把VS Code关了就可以了

奢望 2022-09-18 18:44:04

检查下有可能是一些安全软件在捣蛋,我在打包时就是被下面这个进程锁住了,找了好久才发现,每次打包前都得结束这个进程,但是还会在后台自动启动,已经跟阿里提交过这个问题,但是没人处理
clipboard.png

没企图 2022-09-18 18:44:04

我也遇到这个问题,特别是在运行 clean 命令之后会出现 Error: EBUSY,应该是线程被占用了,我这边打包 APP 是单独启动一个终端,然后先将 build 文件夹内对应生成的部分给删掉(clean 出了点 bug, build 文件夹中的 icons 文件夹别删了),(把占用的那个线程给干掉)再次 build 就行了,你也可以试试。
还有就是别把项目写在 C 盘,有时候权限不够,构建的时候会有问题

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文