19

When using client-side compilation for less, and if there are errors, Less is not showing me what those errors are. It's supposed to insert some HTML, but it seems not to be doing this. The HTML on the page after Less runs looks like:

<html>
  <head>
  <link rel="stylesheet/less" type="text/css" href="/Content/less/all.less">
  <script src="/Content/js/libs/less-1.3.0.min.js" type="text/javascript"></script>
  <style type="text/css" media="screen" id="less:error-message">
   --SNIP--
  }</style>
  </head>
  <body>         
  </body>
</html>

As you can see, the less error css is generated, but not the html.

heneryville
  • 2,853
  • 1
  • 23
  • 30
  • What input generates the errors? Can you boil down the input to as small as possible to still generate the error? – sarnold May 10 '12 at 22:42
  • I'm not really interested in what the error is. I make and fix those a plenty. But it's getting rather hard to debug errors w/o less telling me what it's dying on. – heneryville May 10 '12 at 22:49
  • Are you running `less` at a terminal or via some GUI that might throw away standard error output? I have trouble believing that a tool that doesn't report errors would ever find its third or fourth user... :) – sarnold May 10 '12 at 22:50
  • 1
    I'm using the client side compilation of Less. It's the coolest thing ever. I've used it on other projects, and normally when there is an error it injects HTML onto the page. Not that great for production, but great for dev. However, for some reason it's not doing that now. – heneryville May 10 '12 at 23:05

1 Answers1

41

Add this script before including less.js in your head:

<script type="text/javascript">less = { env: 'development' };</script>

This tells less.js that it is OK to display error messages in the browser as we are still dev'ing the page.

user1267519
  • 426
  • 5
  • 4