Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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,, 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.

share|improve this question
The non-working script is run in the same terminal where lessc works, or in some other ways (cron, a launcher, Alt-F2, other)? – enzotib Sep 26 '11 at 16:12
There's a backtick at the end of your command. Is this typo only here or is it also in your – elmicha Sep 26 '11 at 17:33
yes the backtick was a typo. @enzotib does it matter where the script is being run from, and would it change anything that could cause the error mentioned above? – slang Sep 26 '11 at 18:41
Yes, it matters. In different situation you can have different PATHs. – enzotib Sep 26 '11 at 19:05
Thanks, after researching the $PATH variable I found that lessc was in "/opt/lessc/bin/lessc", which needed to be added to $PATH. – slang Sep 27 '11 at 0:02
up vote 6 down vote accepted

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:


that you found via

type -p lessc
share|improve this answer
Or add the "/actual/path/to/lessc/" to $PATH, by using the command "PATH=$PATH:/actual/path/to/lessc/" in the bash file. And thanks for posting that as a answer (not a comment). – slang Sep 27 '11 at 19:01
npm install -g less

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

share|improve this answer
I execute your command in my ubuntu terminal but I got npm ERR! Refusing to delete: /usr/bin/lessc not in /usr/lib/node_modules/less File exists: /usr/bin/lessc Move it away, and try again. npm ERR! System Linux 3.2.0-90-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "less" npm ERR! cwd /home/best npm ERR! node -v v0.10.40 npm ERR! npm -v 1.4.28 npm ERR! path /usr/bin/lessc npm ERR! code EEXIST npm ERR! not ok code 0 – DaSaDiYa ChaiTAnYa Sep 30 '15 at 18:53

in lubuntu:

$ type -p lessc
$ lessc
El programa «lessc» no está instalado. Puede instalarlo escribiendo:
sudo apt-get install node-less
$ sudo apt-get install node-less
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.