ocajian
ocajian

Reputation: 687

LESS file watcher gives SyntaxError: Unexpected token during compilation

I have set up a LESS file watcher in Webstorm 9.0.2 to take my main.less file and compile it to main.css every time I save edits.

This is how I set it up:

enter image description here

This is what is in my main.less file

body {color:#fff}

However I get the following error in console during my compilation phase:

"C:/Program Files/nodejs/node.exe" main.less

E:\Ornico Work\socialdashboardAngular\app\styles\main.less:1
(function (exports, require, module, __filename, __dirname) { body {
                                                               ^
SyntaxError: Unexpected token {
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Process finished with exit code 8

I am new to Webstorm and have very little idea what that error means and how to fix it. Could anyone out there please help me with this if at all possible?

Upvotes: 0

Views: 1637

Answers (1)

lena
lena

Reputation: 93728

Why do you use node.js to compile your .less files? Node itself can't do this - you need installing LESS compiler (npm install less -g) and specify a path to it as a program in your LESS file watcher. Like:

Program: C:\Users\Your.Name\AppData\Roaming\npm\lessc.cmd
Arguments: --no-color $FileName$
Workingh dir: $FileDir$
Output paths: $FileNameWithoutExtension$.css

Make sure also to tick 'create output from stdout'

Upvotes: 4

Related Questions