How to install and run lessc on top of node.js and

2019-03-24 05:23发布

Hi I am learning LESS and I would like to install lessc on my Windows 7.

Following this tutorial http://verekia.com/less-css/dont-read-less-css-tutorial-highly-addictive

The first step is I dowloaded and installed node.js (node-v0.10.5-x64.msi).

Then in a console, I ran

npm install less -g

I got the following:

npm http GET https://registry.npmjs.org/less
npm http 304 https://registry.npmjs.org/less
npm http GET https://registry.npmjs.org/ycssmin
npm http 304 https://registry.npmjs.org/ycssmin
C:\Users\Me\AppData\Roaming\npm\lessc -> C:\Users\Me\AppData\Roaming\npm\node_modules\less\bin\lessc
less@1.3.3 C:\Users\Me\AppData\Roaming\npm\node_modules\less
+-- ycssmin@1.0.1

Then I ran the following in the same console:

lessc style.less > style.css

But I got

'lessc' is not recognized as an internal or external command, operable program or batch file.

I am not sure where I got wrong. I googled but it seems there is too much stuff, not sure which one is right. Did many tests without any success.

Could someone tell me how to do it or give me a pointer to some place with detailed and latest install info for Windows?

8条回答
疯言疯语
2楼-- · 2019-03-24 05:27

In a console, run the following:

node C:\Users\Me\AppData\Roaming\npm\node_modules\less\bin\lessc style.less > style.css

style.less must be in the console's directory.

查看更多
可以哭但决不认输i
3楼-- · 2019-03-24 05:29

step 1: npm install less -g

step 2: npm i less --save-dev

查看更多
做个烂人
4楼-- · 2019-03-24 05:35

After spending around number of hours hunting around to compile less files, I got very simple answer:

  1. download node-v0.10.26-x64.msi for windows users -> install it -> then
  2. go to any folder(in command prompt) where *.less files are located and run the command "lessc styles.lsss > styles.css". (Example: in command prompt, less is my less folder where *.less files exist) D:\less>lessc styles.less > styles.css
  3. now you will get styles.css files created automatically. Open and see styles.css file
查看更多
戒情不戒烟
5楼-- · 2019-03-24 05:35

Well, you must have NodeJS installed on your machine, use this link to download and install it.

Once installed make sure to restart your machine. Then check whether it is properly installed by running "node -v" and "npm -v" in CMD.

Once that is done run "npm install less -g" and you are ready to compile your less files.

Just go into the directory where your files are and run "lessc style.less style.css"

More can be found on this link.

查看更多
Fickle 薄情
6楼-- · 2019-03-24 05:40

to get lessc working you have to add

C:\Users\Me\AppData\Roaming\npm

to the path

查看更多
放我归山
7楼-- · 2019-03-24 05:41

If you are using windows, don't forget to open the command line console as an administrator.

查看更多
登录 后发表回答