Gulp is a free, open-source, and cross-platform JavaScript toolkit that allows you to automate many development tasks. It is a task runner built on Node.js and npm and used for automating many time-consuming tasks such as minification, concatenation, cache busting, unit testing, linting, optimization, etc. Gulp plugins are simple and designed to do a single job.

In this post, we will show you how to install Gulp on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on the server.

Install Node.js

Gulp requires a Node.js package to be installed in your system.

First, install the Curl with the following command:

dnf install curl -y

Next, add the Node source repository with the following command:

curl -sL https://rpm.nodesource.com/setup_16.x | bash -

Next, install the Node.js using the following command:

dnf install nodejs -y

Once the Node.js is installed, verify the installed version of Node.js with the following command:

node -v

You should see the following output:

v16.6.1

You can also verify the NPM version with the following command:

npm -v

You should see the following output:

7.20.3

Install Gulp CLI

First, you will need to install the Gulp CLI tool in your system. Gulp CLI is a tool used to manage the Gulp application.

You can install it using the NPM command as shown below:

npm install -g gulp-cli

Once the Gulp CLI is installed, you can proceed to the next step.

Install Gulp.js

First, create an application directory with the following command:

mkdir myapp

Next, change the directory to myapp and create a new application with the following command:

cd myapp npm init

You will be asked to provide your application information as shown below:

package name: (myapp) 
version: (1.0.0) 
description: My app
entry point: (index.js) 
test command: "echo "My app" $$ exit 1"
git repository: 
keywords: 
author: hitesh
license: (ISC) 
About to write to /root/myapp/package.json:

{
  "name": "myapp",
  "version": "1.0.0",
  "description": "My app",
  "main": "index.js",
  "scripts": {
    "test": ""echo "My app" $$ exit 1""
  },
  "author": "hitesh",
  "license": "ISC"
}


Is this OK? (yes) yes

Next, add the Gulp module to your application with the following command:

npm install --save-dev gulp

Next, verify the Gulp version with the following command:

gulp --version

You should see the following output:

CLI version: 2.3.0
Local version: 4.0.2

Create an Application with Gulp.js

In this section, we will create a simple Gulp.js application.

First, change the directory to myapp and create a gulpfile.js with the following command:

cd myapp

nano gulpfile.js

Add the following code:

var gulp = require('gulp');

gulp.task('hello', function(done) {
  console.log('My First Gulp App!!!');
  done();
});

Save the file when you are finished then run the Gulp task using the following command:

gulp hello

You should get the following output:

[05:07:52] Using gulpfile ~/myapp/gulpfile.js
[05:07:52] Starting 'hello'...
My First Gulp App!!!
[05:07:52] Finished 'hello' after 4.81 ms

Conclusion

in the above guide, we explained how to install Gulp.js on CentOS 8. You can now start creating your first application using Gulp.js. Feel free to ask me if you have any questions.

<img alt="Hitesh Jethva" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/08/echo/hitesh-80.jpg6126129857a48.jpg" ezimgfmt="rs rscb5 src ng ngcb5" src="data:image/svg xml,”>

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.