I've installed recess as a Ruby gem (though this question also applies if I do it as an npm package), and am using it in Bash script with watchr to process LESS files when they're changed. Whenever a LESS file has bad syntax, the resulting CSS output file is just empty with no error trace (unlike SASS, which puts error output in the file). I know that when using the recess gem in Ruby it yields an error object if there's a problem...where does that error output go if I'm using it from the command line?
1 Answers
As in understand recess does not throw any error on invalid Less code. Only when you try to compile a file which not exist there is an error written to stdout
. Try the following:
>> npm install recess
>> ./node_modules/recess/bin/recess --compile test.less
When the test.less not exists the preceding command will result in:
Error reading file: test.less
Now create a valid less file:
echo "p{ &.class{color:red}}" > valid.less
The compiled output of the following command is also written to stdout
:
>> ./node_modules/recess/bin/recess --compile valid.less
p.class {
color: #ff0000;
}
Doing the same with some invalid output doesn't generate any output:
>> echo "p{ &.class{color" > invalid.less
>> ./node_modules/recess/bin/recess --compile invalid.less
Cause this answer comes a little late you also have to realize that the current version of recess uses less v1.3 whilst the latest version of Less is 1.7.3 now.
I you are able to install recess with npm you should also be able to install the Less command line compiler which generates errors as expected.
>> npm install less
>> echo "p{ &.class{color" > invalid.less
>> ./node_modules/less/bin/lessc invalid.less
The preceding command write the following message to stderr
:
ParseError: missing closing `}` in invalid.less on line 1, column 11:
1 p{ &.class{color
2
You can redirect the stderr
to file by appending the 2>errors.log
code to the command. Now you can for instance running the following command:
>> ./node_modules/less/bin/lessc invalid.less > style.css 2>errors.log
The preceding command writes valid CSS to invalid.less
and error to errors.log

- 48,736
- 16
- 143
- 224