"command not found" when running "lessc" from bash

I have installed lessc via npm, Node.js Package Manager, and when I run lessc from terminal using

lessc /var/www/less/style.less /var/www/css/style.css

it works perfectly.
However, when I put this exact same command in a bash script, less.sh, it returns the error

lessc : command not found.

Also, I need to run this command from a bash script, because incron, a program which I am using to re-compile my less script each time they are modified, is unable to run the command mentioned above, which I believe may be caused by weird methods for handling white-space in the command.


npm install -g less

That installs Less.js globally. Maybe you tried this already but it's not in the documentation on http://lesscss.org/; I had to ask around in #node.js on FreeNode.


Where is the "lessc" executable? Do:

type -p lessc

and take note of the directory, and figure out where that directory is added to your PATH. I think that bash and incron do not source your setup files (.bashrc, etc) the same way. Reading the Bash man page, the INVOCATION section describes how bash finds its startup files. A quick grep through the incron source shows that it doesn't mention .bashrc or .bash_profile.

You could change the "lessc" command in your script to:

/actual/path/to/lessc

that you found via

type -p lessc