javascriptlessgulp-less

Why is my Less outputting a promise error result instead of CSS?


I am trying to debug why gulp-less is not outputting correct CSS and throwing an exception. It seems like less.js seems to be not outputting CSS.

Here is my code:

 var accord         = require('accord');
 var less           = accord.load('less');

 less.render('.class { width: (1 + 1) }', {}, function (e, output) {console.log(output.css);})

The output is

{ state: 'fulfilled', value: { result: undefined } }

Instead of

.class {
  width: 2;
}

as expected on the website: http://lesscss.org/


Solution

  • You have an extra '{}' parameter, I just tried it after removing this and got the correct output. I just had less and accord installed in node_modules. The working code should be:

    var accord         = require('accord');
    var less           = accord.load('less');
    
     less.render('.class { width: (1 + 1) }', function (e, output) {console.log(output.css);})
    

    The { state: 'fulfilled', value: { result: undefined } } is just the error result of the promise returned by accord.