johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 135 forks source link

Error: EEXIST: file already exists after upgrade 2 to 3 #146

Closed mbulfair closed 5 years ago

mbulfair commented 5 years ago

Issue description or question

I'm getting a Error: EEXIST: file already exists, mkdir '/components/loading/dist/min' though it does remove it on the next pass. This happened after upgrading from 2.0.0. Seems to be on a folder in the output folder.

Webpack Config

Environment

Run: npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack

 System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 849.08 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.14.1 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmPackages:
    clean-webpack-plugin: ^3.0.0 => 3.0.0 
    webpack: ^4.33.0 => 4.33.0 
chrisblossom commented 5 years ago

@mbulfair Sorry I don't have enough information to help you. Please provide a minimal repository to demonstrate the problem you are having.

mbulfair commented 5 years ago

@chrisblossom I wish I could, sharing details is private sadly. The repo is in our github enterprise. For now I have to leave things using 2.0. The only option I pass is verbose:true, everything else is default. My best guess is under /dist/ theres a folder /min/ and it's trying do something on cleaning..

chrisblossom commented 5 years ago

I'm not asking for the full repo, just a minimal example. That or fork this repo and put a PR in with a failing test demonstrating the issue. Not sure how I can help otherwise.

sluukkonen commented 5 years ago

One thing I noted is that 3.0 seems to remove files after loaders have run, which I've found very confusing. 2.0 deleted files before loaders.

Maybe this is the same issue?

chrisblossom commented 5 years ago

One thing I noted is that 3.0 seems to remove files after loaders have run, which I've found very confusing. 2.0 deleted files before loaders.

This is because clean-webpack-plugin should not remove any files if the compilation fails, which includes loaders. Loaders should not directly write any files either, instead should use webpack's compilation.assets API.

@mbulfair do you have any plugins that are writing directly to disk? Can you paste your full webpack configuration?

alienriver49 commented 5 years ago

I'm having the same issue after updating to 3.0, but it only happens sporadically. I think that the culprit may be copy-webpack-plugin since I'm using that to copy files around. @mbulfair Are you using this plugin as well?

chrisblossom commented 5 years ago

@alienriver49 can you provide a minimal repository that demonstrates your issue?

alienriver49 commented 5 years ago

@chrisblossom Yep! Let me see if I can get you something together today or tomorrow.

alienriver49 commented 5 years ago

@chrisblossom I created a repo here, but it's not duplicating this issue yet. I know I have seen this issue occur, but it's not consistent. I have noticed another, similar, issue though which can be duped with this repo. After doing the initial build, open the dist/release folder in Windows Explorer, then run the build several times and you'll end up with this error: "Error: EPERM: operation not permitted, mkdir 'C:\Workspace\Github\clean-webpack-plugin-issue-146\dist\release\js'"

I notice this one a lot since I copy the build output to a shared drive after making changes, which I do pretty frequently. This error did start happening with 3.0; with 2.0 Windows Explorer would display a popup or Windows Explorer would bring you back to the root of the repo. I figured it was worth mentioning since it's similar. I will continue to try duplicating the original issue and if I do, I'll update that repo and let you know.

chrisblossom commented 5 years ago

Try placing clean-webpack-plugin first on the plugin list and let me know if that solves the problem. See https://github.com/johnagan/clean-webpack-plugin/issues/150.

alienriver49 commented 5 years ago

That fixed the other issue I mentioned last week! I'm not sure about the original issue, but if I had to guess, that same change would fix it as well.

chrisblossom commented 5 years ago

Thanks @alienriver49 for reporting back. Please let me know if you see the original issue solved for you as well.

@mbulfair Can you report back if https://github.com/johnagan/clean-webpack-plugin/issues/146#issuecomment-507862148 fixes the issue.

mbulfair commented 5 years ago

Apologies on the delay, yes moving it to the top did correct my issue.