Less Installation

This chapterÂ presentsÂ the step by step procedure of Less installation.

With the help of NPM (Node package manager), Less can be installed easily. The operating system and the browser support are the two main requirements for installing LESS.

LESS supports the following browsers.

In order to run LESS example on browser, users need to download and install Node.js package manager.

Installation

With the help of NPM (Node package manager), users can install LESS on the server. Type the following command in the command prompt to install.

npm install â€“g less

Now, some lines in the command prompt are displayed after successful installation.
Below example shows how to create a .less file and convert it to .css file
Create an .html file and .less file in the Node js folder.

HTML file

<head>
<body>
<h1>SPLessons</h1>
<h3>Hello, welcome to splessons</h3>
</body>
</html>


LESS file

@primarycolor: #C00606;
@color:#3664C7;
h1{
color: @primarycolor;
}
h3{
color: @color;
}


Use the below command to compile the .less file to .css

lessc style.less style.css

By running the above command in the command prompt, the .less file automatically gets converted into .css as shown below.

CSS file

h1{
color: #C00606;
}
h3{
color: #3664C7;
}


After makingÂ all the changes, users need to run the .html file in a browser to obtain the output.

Summary

• The operating system and the browser support are the major requirements to install less.
• Node.js package manager is mandatory to run Less files.