jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.2k stars 505 forks source link

EBUSY when the `dist` folder is in use #1122

Open thany opened 2 years ago

thany commented 2 years ago

Current Behavior

When the dist folder is in use, it explodes like that:

node:internal/process/promises:265
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: EBUSY: resource busy or locked, rmdir 'C:\workspaces\awesome-project\dist'] {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'rmdir',
  path: 'C:\\workspaces\\awesome-project\\dist'
}

Expected behavior

No error. Honestly, just bare with me 😀

Suggested solution(s)

The reason this is happening, is because tsdx insists on deleting the folder, rather than emptying it. If it didn't have to delete the actual folder itself, it wouldn't matter if it's open or in use or whatnot.

Additional context

This is easily reproducible on Windows by opening an additional command prompt in the dist folder. There are other scenarios where this error might occur, but this is one way to reproduce it reliably.

Your environment


  System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 16.99 GB / 31.76 GB
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.3.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 99.0.4844.51
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.39)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    tsdx: 0.14.1 => 0.14.1
    typescript: 4.4.2 => 4.4.2

^ and Firefox.