clean-webpack-plugin: Error: ENOTEMPTY: directory not empty
Pretty regularly, I see the following error when starting webpack. My dist
folder is typically a few folders deep. I usually just run webpack again and it works fine, but I thought I’d log an issue in case anyone else is seeing this as well:
C:\path\to\project\node_modules\webpack-dev-server\bin\webpack-dev-server.js:345
throw e;
^
Error: ENOTEMPTY: directory not empty, rmdir 'C:\path\to\project\dist\Views'
at Object.fs.rmdirSync (fs.js:856:18)
at rmkidsSync (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:342:11)
at rmdirSync (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:332:7)
at rimrafSync (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:303:9)
at C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:340:5
at Array.forEach (native)
at rmkidsSync (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:339:26)
at rmdirSync (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:332:7)
at Function.rimrafSync [as sync] (C:\path\to\project\node_modules\clean-webpack-plugin\node_modules\rimraf\rimraf.js:303:9)
at C:\path\to\project\node_modules\clean-webpack-plugin\index.js:164:16
at Array.forEach (native)
at CleanWebpackPlugin.clean (C:\path\to\project\node_modules\clean-webpack-plugin\index.js:90:15)
at CleanWebpackPlugin.apply (C:\path\to\project\node_modules\clean-webpack-plugin\index.js:191:20)
at Compiler.apply (C:\path\to\project\node_modules\tapable\lib\Tapable.js:306:16)
at webpack (C:\path\to\project\node_modules\webpack\lib\webpack.js:32:19)
at startDevServer (C:\path\to\project\node_modules\webpack-dev-server\bin\webpack-dev-server.js:339:14)
at C:\path\to\project\node_modules\webpack-dev-server\bin\webpack-dev-server.js:330:3
at C:\path\to\project\node_modules\portfinder\lib\portfinder.js:160:14
at C:\path\to\project\node_modules\portfinder\node_modules\async\lib\async.js:52:16
at C:\path\to\project\node_modules\portfinder\node_modules\async\lib\async.js:269:32
at C:\path\to\project\node_modules\portfinder\node_modules\async\lib\async.js:44:16
at C:\path\to\project\node_modules\portfinder\lib\portfinder.js:122:16
error Command failed with exit code 1.
OS: Windows 10 clean-webpack-plugin version: 0.1.16 rimraf version: 2.5.4
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 37
- Comments: 33 (1 by maintainers)
A quick search for the error seems to indicate that “it was due to the fact I had an explorer window opened in the directory I was trying to delete”. Could this be the case here as well?
One reason could be, if you have
live server extension
installed ???When I disable it, the error goes away…
npm install
fixed my issue
Hi! I find this error occurs when nodemon is on.
OS: Windows10 15063’s WSL (Ubuntu 16.04)
you saved my day.
I’m hitting this issue as well, but only intermittently. It seems to empty the specified folder(s) and then throws the error. Then on running the build again it removes the now-empty directory successfully.
@chrisblossom Yes I have.
When I start building server code while nodemon is on, it throws an error.
Here is the full error log.
However, the error goes away when I shut nodemon down and build again.
Closed in
v2.0.0
via #99. See johnagan/clean-webpack-plugin#usage. Please open a new issue if you continue to have problems.No argument here. It wasn’t purposeful–I ran foreman under sudo and webpack was one of the commands in the Procfile. It wasn’t intentional.
@dlo I would highly suggest NOT running webpack with sudo. If you are experiencing permission issues without sudo you have other issues that should be solved. Again, running webpack as sudo is dangerous and should be avoided.
In case it’s helpful for anyone else, it turns out I’d run webpack under sudo, so files created in
dist
had root permissions and my usual user didn’t have the rights to delete them. This is why running webpack would throw this error (at least for me).