Lesscss command line compiler Lessc

2019-06-17 06:56发布

问题:

Hi Im trying to get the LessCss command line compiler installed on a Mac.

I've tried

brew install less
Error: No available formula for less

brew install lessc
Error: No available formula for lessc

sudo npm install -g less
..Installs happily..

sudo npm install -g lessc
npm http GET https://registry.npmjs.org/lessc
npm http 404 https://registry.npmjs.org/lessc
npm ERR! 404 'lessc' is not in the npm registry.

npm install less --global
..Installs happily..

npm install lessc --global
npm http GET https://registry.npmjs.org/lessc
npm http 404 https://registry.npmjs.org/lessc
npm ERR! 404 'lessc' is not in the npm registry.

and all I get is

less js/less/style.less > style-theme.css
-bash: less: command not found

lessc js/less/style.less > style-theme.css
-bash: lessc: command not found

Does anyone have any experience with this?


I found something said my path variable might be messed up. This:

/bin/echo $PATH

gets me:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

回答1:

the npm package name for lessc is less

try writing

sudo npm install -g less


回答2:

I will try to provide a complete answer.

All commands must be executed in the Terminal application.

  1. If you don't have it: Install Command Line Tools for Xcode

    xcode-select --install

  2. If you don't have it: Install HomeBrew

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  3. If you don't have it: Install Node.js

    brew install node

  4. Install LessCSS

    sudo npm install -g less

Now you can execute lessc commands.



回答3:

i`m using macOS Siera and work for me, you can try:

  1. install npm using brew:

    brew install node

  2. check node and npm version using:

    node -v npm -v

3.change user to SU using:

sudo su

  1. install less:

npm install -g less

Good Luck.....



标签: macos less