schedule2020-12-11

Electron-Builderでビルドのエラー The process cannot access the file because it is being used by another process

Vue + Electron + TypeScriptでアプリをつくるときのエラー対処。

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

これは、起動中のアプリ(serve, build)が起動していると出る。 アプリを止めてからビルドしよう。

BrowserWindow.hide()で隠れてる場合もあるので、タスクマネージャーなどでプロセスを止める。

環境

  • Windows 10
  • Node.js v14.15.0
  • npm 6.14.8
  • yarn 1.22.5
  • @vue/cli 4.5.9
  • vue-cli-plugin-electron-builder ~2.0.0-rc.5

ログ

>yarn run electron:build

...

 INFO  Building app with electron-builder:
  • electron-builder  version=22.9.1 os=10.0.19041
  • description is missed in the package.json  appPackageFile=C:\git\programmable-calculator\dist_electron\bundled\package.json
  • author is missed in the package.json  appPackageFile=C:\git\programmable-calculator\dist_electron\bundled\package.json
  • writing effective config  file=dist_electron\builder-effective-config.yaml
  • packaging       platform=win32 arch=x64 electron=9.3.5 appOutDir=dist_electron\win-unpacked
  ⨯ remove C:\git\programmable-calculator\dist_electron\win-unpacked\chrome_100_percent.pak: The process cannot access the file because it is being used by another process.
github.com/develar/go-fs-util.EnsureEmptyDir
        C:/Users/develar/go/pkg/mod/github.com/develar/go-fs-util@v0.0.0-20190620175131-69a2d4542206/fs.go:98
github.com/develar/app-builder/pkg/electron.UnpackElectron.func1.1
        Y:/Documents/app-builder/pkg/electron/electronUnpack.go:38
github.com/develar/app-builder/pkg/util.MapAsyncConcurrency.func2
        Y:/Documents/app-builder/pkg/util/async.go:68
runtime.goexit
        c:/go/src/runtime/asm_amd64.s:1373  
ExecError: C:\git\programmable-calculator\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
    at ChildProcess.<anonymous> (C:\git\programmable-calculator\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) {
  exitCode: 1,
  alreadyLogged: false,
  code: 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.