lessc binary not available after installing less v

2019-01-22 01:50发布

问题:

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.

回答1:

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

npm install -g less



回答2:

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