0

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/

TylerH
  • 20,799
  • 66
  • 75
  • 101
pkumar0
  • 2,069
  • 3
  • 14
  • 21

1 Answers1

1

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Anders Elmgren
  • 637
  • 5
  • 12
  • I thought that extra {} was just the options to less.render. I am still getting the same error. Not sure if it is the version of less. > var accord = require('accord'); undefined > var less = accord.load('less'); undefined > > less.render('.class { width: (1 + 1) }', function (e, output) {console.log(output.css);}) undefined { state: 'pending' } – pkumar0 Mar 05 '16 at 01:22
  • 1
    Sorry, got it, thanks: less.render('.class {width: (1 + 1)} ', function (e, output) {console.log(output);}) .class { width: 2; } { state: 'pending' } – pkumar0 Mar 05 '16 at 01:28