Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How to Install Gulp.js on Ubuntu 20.04

    How to Install Gulp.js on Ubuntu 20.04

    By RahulMay 29, 20213 Mins Read

    Gulp is an open-source JavaScript toolkit developed by by Eric Schoffstall helps developers to automate & enhance there workflow. It is a good command-line task runner for Node.js applications. Gulp let us automate processes and run repetitive tasks with ease. It provides a feature of piping output from one task as an input to the next.

    Advertisement

    This tutorial describes you to how to install Gulp on Ubuntu 20.04 LTS Linux systems.

    Step 1 – Installing Node.js

    First of all, you need to install node.js on your system. Use following set of commands to add node.js PPA in your Ubuntu system and install it.

    sudo apt install python-software-properties 
    
    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - 
    sudo apt install nodejs -y 
    

    Make sure you have successfully installed node.js and NPM on your system

    node --version 
    npm --version 
    

    install nodejs for Gulp

    Step 2 – Create Sample Application with NPM

    Gulp can be easily use in your existing Node.js application. You just need to install Gulp package for Node.js in your project. For this tutorial, I am creating a sample Node.js application with NPM.

    mkdir gulp-project && cd gulp-project 
    npm init 
    

    This command will prompt the required information to initialize a new empty project under the current directory.

    Input all the required details for your application. At the end, it will show you the details you input and ask you to confirm.

    About to write to /root/gulp-project/package.json:
    
    {
      "name": "gulp-project",
      "version": "1.0.0",
      "description": "First gulp application by Tecadmin",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [
        "gulp",
        "app"
      ],
      "author": "TecAdmin",
      "license": "ISC"
    }
    
    
    Is this OK? (yes)
    

    Just press enter to save all details in package.json file.

    Step 3 – Installing Gulp on Ubuntu

    Once you have an node.js application. Use the following commands to install Gulp CLI globally on your system.

    npm install -g gulp-cli 
    

    Also install the gulp package in your application. Swith to your application directory and execute the following command.

    npm install --save-dev gulp 
    

    All done, Let’s check the installed version of Gulp CLI on your system and Gulp module in your application with the following command.

    gulp --version 
    
    CLI version: 2.2.0
    Local version: 4.0.2
    

    You have successfully installed the Gulp CLI tool on your system.

    Step 4 – Gulp Hello World Example

    As you have gulp package added your application and installed gulp-cli on your system.

    Next, create a gulpfile.js under the application root directory.

    nano gulpfile.js 
    

    Add a sample code of gulp hello world example program.

    var gulp = require('gulp');
    
    gulp.task('hello', function(done) {
      console.log('Hello World!!!');
      done();
    });
    

    Save your file and close.

    Next run the gulp task with the following command under the application.

    gulp hello 
    

    The above command will run the gulp task named “hello”. As per the above example code, you will see the following results on screen.

    Gulp hello world example

    Conclusion

    This tutorial describes you to install Gulp.js on a Ubuntu system. Visit official documentation page for further development details.

    gulp
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Implementing a Linux Server Security Audit: Best Practices and Tools

    15 Practical Examples of dd Command in Linux

    Iptables: Common Firewall Rules and Commands

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.