37

I went ahead and installed and tested node.js and then I installed LESS CSS via NPM but when I type in the command

lessc styles.less

or

lessc styles.less > styles.css

It tells me -bash: lessc: command not found

I'm in MAC Lion Terminal program

EDIT:

After installing Node you need to run this command

ln -s ~/.npm/less/1.2.1/package/bin/lessc (path to directory you want)

Then you will be able to run less on any of the less files in that directory.

It works but it's not compiling the imports into one CSS file. It just leaves the imports in the file as is. I was hoping I could combine all of the CSS inside the files that I'm importing together.

4
  • Did you restart your terminal's session/reloaded your paths? Commented Jan 30, 2012 at 19:06
  • Whoops! No I didn't. I changed the question because I was able to figure it out. I just needed to install the less in the directories I wanted to use them in. I used this command ===> ln -s ~/.npm/less/1.2.1/package/bin/lessc (path to directory) Commented Jan 30, 2012 at 19:43
  • This is a bug with npm/less see github.com/less/less.js/issues/1464 Commented Aug 3, 2013 at 7:23
  • Note that this problem can occur if you installed node through homebrew on Mac a while ago, new brew node installs should be ok - it's not a less bug, but it was a homebrew bug: github.com/Homebrew/homebrew/issues/21627 Commented Apr 19, 2014 at 6:46

2 Answers 2

34

When you install LESS via npm use the -g option to install it globally.

npm install -g less

Sign up to request clarification or add additional context in comments.

1 Comment

Or if you don't want to pollute the system, install without -g then simply invoke ./node_modules/less/bin/lessc from the directory you were under when doing npm install less
16

When installing packages with npm you have two options:

  1. Install them globally: npm install -g <package>
  2. Install locally in your home directory under ~/.npm: npm install <package>

If you choose option 1 your system should be able to locate the binary lessc. If you choose option 2 you should add ~/.npm/less/path_to_bin_directory to your path:

export PATH=~/.npm/less/path_to_bin_directory:$PATH

or better, if a ~/node_modules directory has been created as a result of installation:

export PATH=~/node_modules/less/path_to_bin_directory:$PATH

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.