DEV Community

Akande Olalekan Toheeb
Akande Olalekan Toheeb

Posted on

Quick tutorial on how to use LESS

Hello folks! This is a quick peep on how to use LESS in your project. This tutorial will teach how to use LESS with Nodejs.


// npm install 

Enter fullscreen mode Exit fullscreen mode

Type in the above code to install Node and Node package manager in your computer.

npm init

Enter fullscreen mode Exit fullscreen mode

Type this in the terminal of your project to include Nodejs in your project. This makes it possible for you to use npm to install various packages or libraries in your project.

After you've set up your html and css files , the next step is to use LESS to your desire.

  • Create a LESS file with .less extension
  • Write some LESS code
  • Now, install LESS in your project by simply typing the below code in your project terminal

// npm install -g less

Enter fullscreen mode Exit fullscreen mode

The -g makes less global in your system i.e It will be available for use in other projects

  • Now you have to compile your LESS code inside your CSS file for it to work inside your html file. This is done by typing the below in your project terminal

// lessc nameoflessfile.less nameofcssfile.css

Enter fullscreen mode Exit fullscreen mode

This will compile your LESS code inside your CSS file and make it available for use.

Note: You don't need to download less again in your next project since it's already global, all you have to do is just create your less file and compile it inside your css file.

Click here to learn more about less.

Thanks for reading..

Top comments (0)