Book Image

Learning less.js

Book Image

Learning less.js

Overview of this book

Table of Contents (22 chapters)
Learning Less.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing Less on the server side


As an alternative to compiling code on the fly, we can always use the command line to perform the same function—Less comes with a built-in command-line compiler that requires the JavaScript-based Node platform to operate.

Installing Less using Node

We took a look at how you can install Node in Chapter 2, Building a Less Development Toolkit; I will assume that you have installed it using the defaults, as outlined in that chapter. At this point, we now need to install the Less compiler, so bring up a command prompt, change to the location of the project folder we created earlier, and enter the following command:

npm install -g less

You will see it run through a download and install of Less at the command prompt:

Once the installation is complete, we can enter the following command to compile a Less file, which uses this syntax:

lessc srcfile [dstfile]

Less will compile the output to stdout; if we want to use a different one, then we can redirect the output:

...