(Last Updated On: November 10, 2018)

In this blog post, I’ll take you through the steps to Install Gulp.js on CentOS 7 / Fedora 29 / Fedora 28. Gulp is a toolkit that helps you automate painful or time-consuming tasks in your development workflow. Gulp has integrations built into all major IDEs for easy use with PHP, .NET, Node.js, Java e.t.c.

Here are the steps to  Install Gulp.js on CentOS 7 / Fedora 29 / Fedora 28.

Step 1: Install Node.js

Gulp requires Node to be installed on the hosting system. Ensure it is installed on your system before you proceed to step 2.

See How to run multiple versions of Node.js on Linux

Install Node.js on CentOS 7

curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -
sudo yum install -y nodejs
sudo yum install gcc-c++ make

Install Node.js on Fedora 29 / Fedora 28

For Fedora 29 / Fedora 28, install Node.js by running the commands below.

Install V8 Javascript Engine:

sudo dnf install nodejs

To Install V11 Javascript Engine, use:

curl -sL https://rpm.nodesource.com/setup_11.x | sudo -E bash -
sudo dnf install -y nodejs
sudo yum install gcc-c++ make

Check Node version:

# node --version
v11.1.0

$ npx --version
6.4.1

Step 2: Install Gulp.js on CentOS 7 / Fedora 29 / Fedora 28

After installing Node.js, proceed to install Gulp.js on CentOS 7 / Fedora 29 / Fedora 28.

sudo npm install --global gulp-cli

This will make gulp to be available globally on the system.

Verify your gulp versions:

$ gulp --version
[20:12:23] CLI version 2.0.1

Step 3: Install the gulp package in your dev Dependencies

To install gulp package in your dev Dependencies, do it like below:

Create a Project directory:

$ npx mkdirp project1
npx: installed 2 in 1.355s

Navigate to Project directory and create package.json file

$ cd project1
$ npm init

This will guide you through giving your project a name, version, description, etc. Sample output is below:

This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (project1) 
version: (1.0.0) 
description: My first Project
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /home/jmutai/project1/package.json:

{
  "name": "project1",
  "version": "1.0.0",
  "description": "My first Project",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Install the gulp package in your devDependencies

npm install --save-dev [email protected]

Check gulp versions:

$ gulp --version
[20:22:52] CLI version 2.0.1
[20:22:52] Local version 4.0.0

Create a gulpfile

Create a file named gulpfile.js in your project root:

vim gulpfile.js

Add these contents:

function defaultTask(cb) {
  // place code for your default task here
  cb();
}

exports.default = defaultTask

Test by running the gulp command in your project directory:

$ gulp
[20:25:17] Using gulpfile ~/project1/gulpfile.js
[20:25:17] Starting 'default'...
[20:25:17] Finished 'default' after 5.51 ms

To run multiple tasks, you can use gulp <task> <othertask>.