[Updated] Gulp is an open-source JavaScript toolkit and a cross-platform used as a streaming build in front-end web development. It is a task runner built on Node.js and npm, used for automation of time-consuming and repetitive tasks involved in web development like minification, concatenation, cache busting, unit testing, linting, optimization, etc. In this article, you will learn How To Install Gulp.js On Ubuntu 18.04. If you wish to prepare your own Ubuntu VPS, count on our technical team and register your order on Eldernode.
Gulp is a toolkit that helps developers with the automation of painful workflow during development. To install Gulp you first need to install Node.js, so you will start by installing Node.js on your Ubuntu by following the instructions below and then install Gulp.
Table of Contents
Gulp.js Vs. Other Task runners
The main reason that Gulp is different is that it uses Node streams. Since gulp pipes output from one task as an input to the next, it reads the file once and then processes it through multiple tasks. Gulp will finally write the output file. So, gulp is faster because there is no need to create and read intermediary files on the hard drive.
Prerequisites to install Gulp.js on Ubuntu 18.04
To let this tutorial work better, please consider the below Prerequisites:
A non-root user with Sudo privileges.
To set up, follow our Initial server setup on Ubuntu 18.04.
How to Install Gulp.js On Ubuntu 18.04 LTS
Gulp is a command-line task runner for Node.js. Using Gulp allows you to automate processes and run repetitive tasks with ease. Let’s go through the steps of this guide and install the Gulp.js toolkit on Ubuntu 18. This way of installation is also useful for those who wish to install Gulp.js on Ubuntu 16.04.
Step 1:
First of all, you need to install Nodejs on your system. To add node.js PPA in your Ubuntu system and install it, run:
sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
Then, you can use the command below to check if it is installed successfully or not:
node --version
npm --version
Step 2:
Once Node.js and Npm are installed, you are ready to install Gulp. So, type:
sudo npm install -g gulp
If all is done correctly, Gulp should be installed now. To check the installed version of bower on your system, use the following command:
gulp --version
In this way, you can view the CLI and Local versions of your current gulp.
To install the gulp command-line utility, run:
npm install --global gulp-cli
How to create a project directory in Gulp.js
At this point, you can create a project directory and navigate into it. To do this, use the following commands:
npx mkdirp my-project
cd my-project
How to create a package.json file in your project directory
To receive your project a name, version, description, etc, you can run the following command and create a package.json file:
npm init
Finally, run the following command to install the gulp package in your devDependencies:
npm install --save-dev gulp
Conclusion
In this article, you learned How to Install Gulp.js On Ubuntu 18.04. Gulp helps you to automate numerous tasks in your workflow. You can now Spin up a web server and reload the browser automatically whenever a file is saved. Also, you can refer to a related article and learn How to configure Gulp.js on Ubuntu 20.04.