Qadry
unixcop Admin

How to install GulpJS on Ubuntu 21.04

Introduction

Gulp is a tool to automate tasks, mostly on the front-end layer. It is developed in javascript and works on NodeJS so it can run on any system.

You can apply many transformations to your files while in memory before anything is written to the disk—significantly speeding up your build process.

Installing GulpJS on Ubuntu 21.04

Install NodeJS on Ubuntu 21.04

This tool built with NodeJS, so we have to install it on our system.

So, in a terminal, make sure you have Ubuntu up to date.

sudo apt update && sudo apt upgrade

Install the software-properties-common package which usually already included, but it’s better to be sure.

sudo apt install software-properties-common

Also we will be working with 16.x version of NodeJS, so we have to install it via the external repository provided by the developers. To add the repository, we have to run the following command:

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

Now we can install NodeJS by running the following command.

sudo apt install nodejs

Check Versions to see if the process was successful.

node --version
npm --version 

Install GulpJS on Ubuntu

Now we need to create a folder where the Gulp installation will be. Then we need to access it.

mkdir project
cd project
npm init
Then start the NodeJS project

The package.json file willbe created .

Now install gulp-cli which is one of the packages needed to use Gulp.

sudo npm install -g gulp-cli

And install the Gulp package

sudo npm install --save-dev gulp

After this, you can verify the installation by running:

gulp --version

Testing the installation

Create a file called gulpfile.js with your text editor. I will use vim.

vim gulpfile.js

And add the following:

var gulp = require('gulp');

gulp.task('test', function(done) {
  console.log('Hello visitors from unixcop');
  done();
});

In this case, I’ve defined a task that just prints a greeting on the screen.

To run it, just type

gulp test

So, Gulp installed and ready to be useful.

Conclusion

Gulp contributes to the automation of many tasks that a front-end developer may find tedious. This makes it a valuable tool for many of them. In this post, we have taken you through a series of steps to help you install Gulp on Ubuntu.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x