LESS compile error ParseError: Syntax Error on lin

2019-02-04 16:10发布

问题:

I am trying to do some customisation on my existing bootstrap less file by importing import my own less file into existing bootstrap.less.

I thought it would be simple, however I've spend painful couple hours already to try to make new less compiled.

every time I add my file in I got:

ParseError: Syntax Error on line 1 in C:\xxx\content\bootst rap\less\xxx.form.less:9:999 8 }

My own less file:

.form-unit {
  background-color: #F5F5F5;
  border-radius: 6px 6px 6px 6px;
  margin-bottom: 30px;
  padding: 10px;
  min-height: 170px;
  position:relative;
}

Anyone have same problems? what did i missed???

I compiled it online not surprisingly it works, I am so confused

回答1:

Are you using SimpLESS as your LESS compiler? If so there's a bug where it can't read files encoded in UTF-8 with BOM. Just convert your file to UTF-8 without BOM and it will work.



回答2:

To anyone using Visual Studio and continuing to tear their hair out with the problem above (I've been in the same boat for the last hour or so, and the approved answer above didn't work for me), I'd recommend getting hold of the Web Essentials extension.

It allows for instant compilation of LESS files into minified CSS whenever they are saved in much the same way as SimpLESS does. No complaints about encoding, line endings or anything else!



回答3:

For all .less files used in Visual Studio, you need to change the UTF encoding....

File > Advanced Save Options...
Set "Encoding" to "Unicode (UTF-8 without signature) - codepage 65001

Once you do this, the Simpless compiler will work for your files.



回答4:

If you are using Visual Studio, make sure that you didn't accidentally add the included file to the compile list. Check compilerconfig.json and make sure you aren't trying to compile both the main SASS file and the included one.