在用 electron-builder 打包时,时常会出现 “The process cannot access the file because it is being used by another process.” 这个报错,字面意思是因另外一个进程在使用文件,所以现在不能操作此文件。报错如图:

The process cannot access the file because it is being used by another process

由于这个报错是偶尔发生的,排除了很久才解决,故做下笔记。

网上的方法

vscode "设置" 里排除掉 "win-unpacked" 文件夹的监测

{
  "files.watcherExclude": {
    "**/build/win-unpacked/**": true
  }
}

理由是 vscode 会检测项目文件的变化,然而按照此方法设置了依旧还是会报错。所以根本原因不在此。。

解决

不要启用 “live server” 插件!

因为项目要做自动更新,图个方便,开启了 “live server” 服务,由于此插件就像一个服务器,已开启就会检测项目的根目录,开启后,即使再关闭,其检测文件的进程依旧存在,这是就需要重启 vscode 了。

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-11-03
  • 2021-05-25
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-01-25
  • 2021-11-05
  • 2021-06-04
相关资源
相似解决方案