Less isn't showing me its errors
Asked Answered
S

2

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.

Scrounge answered 10/5, 2012 at 22:40 Comment(4)
What input generates the errors? Can you boil down the input to as small as possible to still generate the error?Strait
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.Scrounge
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... :)Strait
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.Scrounge
A
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.

Abib answered 2/7, 2012 at 6:55 Comment(3)
Oh... You're saved a lot of my time! Is this feature documented anywhere?Subjunction
Thanks, this saved me too! I don't remember having to do this before, is this a new thing?Berube
@TestSubject528491 Yeah, it mentions it, but it doesn't say what it does (though after you know, it's pretty obvious)Obturate
M
0

I am very new with SCSS and came to this post to know the error of SCSS with LESS. I just want to say many thanks, who asked it @heneryville

<style type="text/css" media="screen" id="less:error-message">

and also thanks for the answer of it :

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

And many thanks @user1267519

I can see the SCSS errors now easily:

enter image description here

Now I can solve errors easily.

Mussorgsky answered 9/10, 2023 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.