less-plugin-clean-css icon indicating copy to clipboard operation
less-plugin-clean-css copied to clipboard

Windows error runing via gulp: Potentially unhandled rejection [2] Error: ENOENT, $stdin

Open gotofritz opened this issue 10 years ago • 12 comments
trafficstars

Hi

I get the following error when running less-plugin-clean-css via gulp windows:

 Potentially unhandled rejection [2] Error: ENOENT, open 'C:\SOME\PATH\$stdin'
       at Error (native)

No error in OS X.

My gulp task

var less = require("gulp-less");
var LessPluginCleanCSS = require("less-plugin-clean-css");
var sourcemaps = require("gulp-sourcemaps");

gulp.task(taskName, function () {
  var lessArgs = {};
  lessArgs.plugins = [];
  // if I remove the following line, I don't get any errors
  lessArgs.plugins.push(new LessPluginCleanCSS({ advanced: true }));

  return gulp
  .src("/PTH/TO/CSS/**/main.less")
  .pipe(sourcemaps.init())
  .pipe(less(lessArgs))
  .pipe(sourcemaps.write("PTH/TO/JS"))
  .pipe(gulp.dest("htdocs/css/"));
});

Any ideas? Thanks in advance.

gotofritz avatar May 18 '15 16:05 gotofritz

Sorry, no ideas! Possibly something to do with sourcemaps? if you take that out and leave the plugin in, does it work?

lukeapage avatar May 26 '15 08:05 lukeapage

I'm experiencing the same error in Windows. If either sourcemaps or clean-css is removed, then it works. Also, in the Less I've place a multi-line comment at the top. If this comment is removed or changed to be a single line comment, then everything works.

/*
Test
*/
.test {color:red;}

Here is a simple gist with the code I'm using: https://gist.github.com/Kruegs/3b4b720f9fe36f1d6532

Kruegs avatar Jun 18 '15 18:06 Kruegs

Does this help anyhow, guys? https://github.com/jakubpawlowicz/clean-css/issues/593#issuecomment-117538125

jakubpawlowicz avatar Jul 01 '15 08:07 jakubpawlowicz

@jakubpawlowicz There's exactly the same problem with less-plugin-autoprefix (see the referenced issue above). So aparently it's some weird incompatibility in how gulp-less and these plugins handle sourcemaps but it's hard to say for sure w/o deeper tests/debugging (unfortunately it looks like neither @lukeapage nor me actually use gulp so it may take for a while until we'll get to this to investigate... Unless someone else would be so kind to take it. :)

seven-phases-max avatar Jul 01 '15 13:07 seven-phases-max

I use gulp in some projects with less-plugin-clean-css and autoprefix on windows, and haven't had any problems. then again I haven't switched on sourcemaps either as they don't need it yet.

I suspect the problem is that gulp uses streams - which should be fine since the gulp-plugin can wrap less and use it like an asynchronous stream. I've reviewed this plugin and less.js and I can't see anywhere that less-node write the sourcemap - its only done by lessc, so that means it's either gulp, gulp-less, clean-css or the sourcemaps code.

Someone who gets the error needs to debug, but it doesn't look to me like less is doing anything incompatible.

lukeapage avatar Jul 01 '15 13:07 lukeapage

for the interested, https://github.com/jakubpawlowicz/clean-css/issues/593 has part of an analysis, @jakubpawlowicz will investigate next

lukeapage avatar Jul 01 '15 15:07 lukeapage

Same error here, removing the less plugins or sourcemaps makes it work again.

For now, I'm enabling one or the other depending if it's for debug or release

pgrm avatar Jul 19 '15 01:07 pgrm

Getting similar issue on windows only. any updates?

amcdnl avatar Aug 17 '15 20:08 amcdnl

@seven-phases-max I have some knowledge of gulp, although like everyone else here, I'm limited on time.

I wonder what it would take for Less to simply be Gulp-compatible, which would eliminate the need for gulp-less and alleviate some of the back and forth of an issue like this.

matthew-dean avatar Aug 23 '15 05:08 matthew-dean

to be clear, this is a clean css issue and needs ti be investigated and fixed there. see the linked issue above.

lukeapage avatar Aug 23 '15 14:08 lukeapage

Ah.

matthew-dean avatar Aug 23 '15 15:08 matthew-dean

I'm seeing it without gulp-clean-css, just using gulp-sourcemaps together with gulp-less is enough.

mgol avatar May 09 '16 11:05 mgol