5

I'm on OS X.8 and a newbie at Node & LESS. I thought I installed lessc earlier and when I go to /usr/local/bin I see lessc

but for the life of me, I can't run it. Anytime I do run it, I see -bash: lessc: command not found

So I've tried the tip here which has the following:

ln -s ~/.npm/less/1.3.3/package/bin/lessc my/local/dir

My local dir happens to be on a second drive on my laptop, here's the path: /Volumes/Mac17/Users/denis2/Sites/staging/assets/less

With all that said, I try and run:

lessc boostrap.less

and still get

-bash: lessc: command not found

I'm totally lost here and any help would be tremendous.

Community
  • 1
  • 1
SWL
  • 3,794
  • 6
  • 23
  • 32

2 Answers2

4

Just follow the steps :

  1. Make lessc executable by your user(permission denied means you dont have permission to run) like chmod 755 lessc
  2. Export the location of lessc into the PATH like export PATH=$PATH:/home/user/folder/path/less/bin (where lessc is present)
  3. Use lessc lessc boostrap.less

You should put PATH export in environment so that you dont have to do it every time you login See here : Setting environment variables in OS X?

Community
  • 1
  • 1
user568109
  • 47,225
  • 17
  • 99
  • 123
  • This worked! Once I chmod 755 that let me finally compile without issue. I updated your line 3 to output a CSS file. I read the other post on environment.plist but couldn't take away what to do exactly so I'll stick with what works for now. Thanks for your help. – SWL Feb 14 '13 at 04:55
3

If you enter just lessc, it is searched in the $PATH. For security reasons, the current directory is not in the $PATH. Try

./lessc bootstrap.less

or, if that doesn't work, simply

~/.npm/less/1.3.3/package/bin/lessc bootstrap.less

If you get a Permission Denied error then, you may need to mark the file as executable. Use

chmod a+x ~/.npm/less/1.3.3/package/bin/lessc

to do that. You may also need to call node directly, if it isn't in your $PATH.

phihag
  • 278,196
  • 72
  • 453
  • 469
  • Thanks for the response. Both generated errors. The first snippet produced: -bash: ./lessc: No such file or directory – SWL Feb 13 '13 at 04:43
  • The second one produced -bash: /Users/denis/.npm/less/1.3.3/package/bin/lessc: Permission denied – SWL Feb 13 '13 at 04:44
  • Would this be because Node is installed on my primary startup drive but the less folder is on a secondary drive/volume? – SWL Feb 13 '13 at 04:53
  • @SWL Nope. See my updated answer. You may also want to have a look at lessc and check that its [shebang](http://en.wikipedia.org/wiki/Shebang_(Unix)) is correct. – phihag Feb 14 '13 at 10:38