question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EISDIR: illegal operation on a directory, read

See original GitHub issue

Trying to use laravel-mix-purge-css, I have this error message running npm run prod :

Error: EISDIR: illegal operation on a directory, read
    at Object.fs.readSync (fs.js:675:18)
    at tryReadSync (fs.js:540:20)
    at Object.fs.readFileSync (fs.js:583:19)
    at e.value (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\purgecss\lib\purgecss.js:1:7949)
    at e.value (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\purgecss\lib\purgecss.js:1:6214)
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:244:97
    at Array.forEach (<anonymous>)
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:195:39
    at Array.forEach (<anonymous>)
    at Compilation.<anonymous> (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:181:40)
    at next (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\tapable\lib\Tapable.js:204:14)
    at Compilation.<anonymous> (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\dist\index.js:275:11)
    at Compilation.applyPluginsAsyncSeries (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\tapable\lib\Tapable.js:206:13)
    at applyPluginsAsyncSeries (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\webpack\lib\Compilation.js:659:9)
    at next (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\tapable\lib\Tapable.js:202:11)
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\dist\index.js:244:13
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:473:16
    at iteratorCallback (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1050:13)
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:958:16
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\dist\index.js:227:15
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:473:16
    at iteratorCallback (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1050:13)
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:958:16
    at C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\extract-text-webpack-plugin\dist\index.js:216:21
    at rebuilding.forEach.cb (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\webpack\lib\Compilation.js:528:29)
    at Array.forEach (<anonymous>)
    at callback (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\webpack\lib\Compilation.js:528:15)
    at processModuleDependencies (C:\Users\Val\PhpstormProjects\The-One-True-Bubbleflat\www\node_modules\webpack\lib\Compilation.js:547:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

this is my webpack.mix.js

mix.webpackConfig({
    plugins:
        [
            new WebpackShellPlugin({onBuildStart:['php artisan lang:js resources/assets/js/traduction/messages.js --no-lib'], onBuildEnd:[]}),
            new LiveReloadPlugin(),
        ],
});

mix.js('resources/assets/js/app.js','public/js')
    .sass('resources/assets/sass/app.scss', 'public/css')
    .options({ processCssUrls: false })
    .purgeCss();

if (mix.inProduction()) {
    mix.version();
}

as in #2, I just upgrade from laravel-mix fom 0.* to 2.0.0 to use this package

Hope somebody can help 😃 Val

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
jonhftcommented, Jun 12, 2018

+1. Same issue

4reactions
wiljanslofstracommented, Jul 29, 2018

I had the exact same error, but after some digging the problem in my case was because of a folder ending in ‘.js’.

I suspect that purgecss or laravel-mix-purgecss searches for everything ending with the extensions defined in the config, including css, js, etc. In my case that also returned a folder – purgecss only works on files and throws this error.

To see the folder that throws an error you can temporarily add a console log in node_modules/purgecss/lib/purgecss.js on line 645, change:

var file = _step6.value;

var content = fs.readFileSync(file, 'utf8');

to:

var file = _step6.value;
                            
if (fs.lstatSync(file).isDirectory()) {
  console.log(file);
}

var content = fs.readFileSync(file, 'utf8');

Rename the folder(s) that gives problems, and rename it.

Not the best solution, but it solves the problem for now. I’ll see if there’s a possibility for changing the glob matching to only match files, and not folders.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NPM stuck giving the same error EISDIR: Illegal operation on ...
EISDIR stands for "Error, Is Directory". This means that NPM is trying to do something to a file but it is a directory....
Read more >
Error: EISDIR: illegal operation on a directory, read · Issue #658
What is the current behavior? I have an project which is a react native project called th_views.rn and in the project there's a...
Read more >
Illegal operation on a directory, read at error ( - YouTube
Windows : NPM stuck giving the same error EISDIR : Illegal operation on a directory, read at error (native) [ Beautify Your Computer ......
Read more >
EISDIR: illegal operation on a directory when enable Remote ...
Error: EISDIR: illegal operation on a directory, read at Object.readSync (fs.js:614:3) at tryReadSync (fs.js:383:20) at Object.
Read more >
eisdir: illegal operation on a directory - You.com
EISDIR stands for "Error, Is Directory". This means that yarn is trying to do something to a file but it is a directory....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found