Gulp is a free, open-source, and cross-platform task runner tool that uses Node.js as a platform. It helps developers to automate painful tasks such as CSS and HTML minification, concatenating library files, and compiling the SASS files in the development workflow. Generally, it is used to run front-end tasks such as spinning up a web server or reloading the browser automatically whenever a file is saved.
In this post, we will show you how to install Gulp.js on Oracle Linux 8.
Step 1 – Install Node.js on Oracle Linux 8
Gulp uses Node.js and NPM framework, so you will need to install both packages to your system.
First, install the curl package using the following command:
dnf update -y dnf install curl -y
Next, list all available Node.js versions using the following command.
dnf module list --all nodejs
You will see the following output.
Name Stream Profiles Summary nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime nodejs 12 common [d], development, minimal, s2i Javascript runtime nodejs 14 common [d], development, minimal, s2i Javascript runtime nodejs 16 common [d], development, minimal, s2i Javascript runtime nodejs 18 common [d], development, minimal, s2i Javascript runtime nodejs 20 common, development, minimal, s2i Javascript runtime
Next, enable the Node.js version 20 repo using the following command.
dnf module enable nodejs:20
Next, install the Node.js by running the following command:
dnf install nodejs -y
Once Node.js is installed, you can verify the Node.js version using the following command:
node --version
You will get the following output:
v20.0.0
You can also verify the NPM version using the following command:
npm -v
Sample output:
10.1.0
Step 2 – Install Gulp.js
Before starting, you will need to install the Gulp CLI tool to install and manage the Gulp application.
You can install the Gulp CLI tool using the following command:
npm install -g gulp-cli
After the installation, create a directory for the Gulp application:
mkdir gulp
Next, change the directory to gulp and create a gulp application with the following command:
cd gulp npm init
You will be asked to provide answers to several questions for your new application:
package name: (gulp) version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) About to write to /root/gulp/package.json: { "name": "gulp", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" } Is this OK? (yes) yes
Next, run the following command to install the Gulp module:
npm install --save-dev gulp
Next, verify the Gulp installation using the following command:
gulp --version
You should see the following output:
CLI version: 2.3.0 Local version: 4.0.2
Step 3 – Create a Gulp Application
After installing Gulp, you will need to create a sample Gulp application to test it.
First, create a project directory using the following command:
mkdir project
Next, change the directory to project and create a Gulp application with the following command:
cd project nano gulpfile.js
Add the following code:
var gulp = require('gulp'); gulp.task('hello', function(done) { console.log('Hello World Application!!!'); done(); });
Save and close the file, then run the Gulp application using the following command:
gulp hello
You will get the following output:
[12:30:52] Using gulpfile ~/gulp/project/gulpfile.js [12:30:52] Starting 'hello'... Hello World Application!!! [12:30:52] Finished 'hello' after 2.11 ms
Conclusion
In this post, we explained how to install Gulp.js on Oracle Linux 8. We also created a sample application using Gulp.js. You can now use Gulp in your environment to automate repetitive tasks with ease. For more information, visit the Gulp.js official documentation page. Try it on VPS hosting from Atlantic.Net!