Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ENOTEMPTY: directory not empty, rmdir during rollup #307

Closed
2 of 3 tasks
MrMaxie opened this issue Mar 7, 2024 · 2 comments
Closed
2 of 3 tasks

Error: ENOTEMPTY: directory not empty, rmdir during rollup #307

MrMaxie opened this issue Mar 7, 2024 · 2 comments
Labels
need reproduction Should provide a reproduction

Comments

@MrMaxie
Copy link

MrMaxie commented Mar 7, 2024

Describe the bug

I'm just setting rollupTypes value to true, like:

dtsPlugin({
    rollupTypes: true,
}),

But it's enough to have issues in case of my code.

vite v5.0.10 building for production...
✓ 175 modules transformed.

[vite:dts] Start generate declaration files...
dist/style.css                 86.12 kB │ gzip: 11.54 kB
dist/App.js                     0.49 kB │ gzip:  0.23 kB
dist/[...].js                   1.68 kB │ gzip:  0.67 kB
dist/[...].js                   2.43 kB │ gzip:  0.81 kB
dist/[...].js                 108.06 kB │ gzip: 18.00 kB
[vite:dts] Start rollup declaration files...
Analysis will use the bundled TypeScript version 5.3.3
[vite:dts] ENOTEMPTY: directory not empty, rmdir 'E:/[...]/app/dist/[component-path]'
✓ built in 18.17s
error during build:
Error: ENOTEMPTY: directory not empty, rmdir 'E:/[...]/app/dist/[component-path]'
    at rmdirSync (node:fs:1219:10)
    at removeDirIfEmpty (file:///E:/[...]/app/node_modules/vite-plugin-dts/dist/index.mjs:126:5)
    at removeDirIfEmpty (file:///E:/[...]/app/node_modules/vite-plugin-dts/dist/index.mjs:111:14)
    at removeDirIfEmpty (file:///E:/[...]/app/node_modules/vite-plugin-dts/dist/index.mjs:111:14)
    at Object.writeBundle (file:///E:/[...]/app/node_modules/vite-plugin-dts/dist/index.mjs:1004:11)
    at async Promise.all (index 0)
    at async PluginDriver.hookParallel (file:///E:/[...]/app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18570:9)
    at async file:///E:/[...]/app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19562:13
    at async catchUnfinishedHookActions (file:///E:/[...]/app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18986:16)
    at async build (file:///E:/[...]/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:66815:22)

I am close to certain that this is due to how the built-in FS library works on Windows. It is also significant that the folder is indeed non-empty. So it's probably a matter of a race of conditions.

What do I suggest?
I suggest using libraries that already assume such scenarios and allow recursive folder deletion regardless of the operating system (fs-extra?)

Reproduction

Non-applicable

Steps to reproduce

  1. Create scaffolded project npm create vite@latest
  2. Create multilevel nested directories with multiple files, e.g components
  3. Install vite-plugin-dts
  4. Set-up plugin like instructions say, with rollupTypes equal to true
  5. Run vite build or npm run build

Note: I do not have 100% reproductive scenario. In some projects there are this issue, in others works fine.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 1.31 GB / 15.88 GB
Binaries:
    Node: 20.10.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
    npm: 10.2.5 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD

Validations

@qmhc
Copy link
Owner

qmhc commented Mar 8, 2024

Is it reproduced absolutly when building?

@qmhc
Copy link
Owner

qmhc commented Mar 19, 2024

I cannot reproduce this via the steps you provided. Please provide a reprodution.

@qmhc qmhc added the need more info Further information is requested label Mar 19, 2024
@qmhc qmhc added need reproduction Should provide a reproduction and removed need more info Further information is requested labels Apr 3, 2024
@qmhc qmhc closed this as completed May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need reproduction Should provide a reproduction
Projects
None yet
Development

No branches or pull requests

2 participants