Open In App

How to import LESS through npm ?

LESS stands for Leaner Style Sheets. It is a backward-compatible language extension for CSS. Web pages can be styled by writing appropriate code in a file with .less extension and then converting it in a CSS file.

Steps to install LESS:
Step 1: To install LESS, first make sure that node and npm are already installed in the system. If not, then install them using the instructions given below.



Step 2: Now install LESS using the command:

npm install less



Note: Install the LESS npm module globally so that it can be used by any project, use the command npm install less -g. If you are executing this on a Mac or Linux machine, you may need to add “sudo” to the beginning of this command.
Step 3: To compile .less file, use the command:

lessc input.less output.css

Note: Make sure that you run this command in the same folder which contains input.less file. This completes the compilation of the LESS file to CSS file which can now be added to the HTML file.

Article Tags :