Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a LESS file watcher in PHPStorm 6 using node.js on Windows?

I'm a recent convert to PHPStorm and absolutely loving it. I'm trying to get the 'File Watcher' to work with my LESS code, and I want it to use the lessc command. I have node.js installed and the command 'lessc' works from the windows command prompt, but it doesn't want to work within PHPStorm.

Here is my configuration for the file watcher:

enter image description here

When the file watcher runs, I get this error appear continuously:

An exception occurred while executing watcher 'LESS'. Watcher is disabled. Fix it.: Cannot run program "C:\Users\Jason\AppData\Roaming\npm\lessc" (in directory "F:\Plan2Share_v1\public\css"): CreateProcess error=193, %1 is not a valid Win32 application

As soon as I enable the watcher again, it somehow disables and throws me the above error again. I'm very new to node.js and PHPStorm. Any direction on where I might be going wrong would be greatly appreciated.

EDIT: Following @josh3736 's direction. I now get his error in the Run console of PHPStorm.

"C:\Program Files\nodejs\node.exe" C:\Users\Jason\AppData\Roaming\npm\lessc F:\Plan2Share_v1\public\css\style.less

C:\Users\Jason\AppData\Roaming\npm\lessc:2 basedir=`dirname "$0"`
        ^ SyntaxError: Unexpected token ILLEGAL
    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:901:3
like image 398
JasonMortonNZ Avatar asked Apr 02 '13 01:04

JasonMortonNZ


1 Answers

That error tells us that PHPStorm is calling CreateProcess, which can only start executables. It cannot run scripts/batch files, which is what lessc is. (PHPStorm would have to use ShellExecute for that.)

To work around this limitation, you'll have to specify the Node installation (C:\Program Files\nodejs\node.exe most likely) as the executable, and the arguments should probably be something like C:\Users\Jason\AppData\Roaming\npm\node_modules\less\bin\lessc $FileName$

like image 164
josh3736 Avatar answered Oct 30 '22 22:10

josh3736