Run Gulp as a Windows Service with AlwaysUp

How to Run Gulp as a Windows Service with AlwaysUp

Automatically start Gulp in the background whenever your PC boots. Keep it running 24/7 — without anyone having to log on. Set it and forget it!

Gulp.js is an open-source JavaScript toolkit focused on automating common tasks for building and maintaining web applications/environments.

Many Gulp commands are designed to be run on demand or on a schedule. If those tasks must be invoked periodically, it's best to use the Windows Task Scheduler.

However, there is another class of "watch" tasks that must run all the time. For instance, a Gulp file watcher patiently monitors the file system and springs into action whenever a change is detected. For those 24/7 tasks, running Gulp as a robust Windows Service is ideal — and that's where AlwaysUp can help.

To install Gulp as a Windows Service with AlwaysUp:

  1. Install Gulp globally, if necessary.

    Afterwards, install Gulp in your local project and ensure that you can run the default command in your gulpfile.js.

    For this tutorial, we created a project in "C:\Projects\test1" and coded a simple Gulp task that watches for updates to CSS files in a project folder. When a change is detected, the task prints a line to the console.

    Here's our gulpfile.js:

    const { watch } = require('gulp');
    
    function defaultTask(cb) {
        console.log("Watching for changes to CSS files...");
        const watcher = watch(['src/*.css']);
        watcher.on('all', function(event, path) {
            console.log(`Operation: "${event}"; File: "${path}"`);
        });
        cb();
    }
    
    exports.default = defaultTask
    

    We validated that the task runs properly and detects file changes as designed:

    Gulp is working properly

    Gulp is ready to go!

  2. Next, download and install AlwaysUp, if necessary.

  3. Start AlwaysUp.

  4. Select Application > Add to open the Add Application window:

    Add Application

  5. On the General tab:

    • In the Application field, enter the full path to the script that starts Gulp, gulp.cmd. If you installed Node.js and NPM in the default (global) location, this is:

      C:\Users\<USER-NAME>\AppData\Roaming\npm\Gulp.cmd
      where <USER-NAME> is the name of the Windows account where you installed Node.js.

    • In the Start in directory field, enter the full path to the folder containing your Gulp project. Gulp must run in that folder to find your project's files.

      This is "C:\Projects\test1" on our system.

    • In the Start the application field, choose Automatically, but shortly after the computer boots. With this setting, Node.js and Gulp.js will start a couple of minutes after boot — once all the machine's critical services are completely up and running.

    • And in the Name field, enter the name that you will call the application in AlwaysUp. We suggest Gulp but you can specify another name if you like.

    Gulp Windows Service: General Tab

  6. Move to the Logon tab and enter the user name and password of the account where you installed and run Gulp. You should avoid using the default system account as Node.js and Gulp were never installed there.

    Gulp Windows Service: Logon Tab

  7. When installed as a Windows Service, Gulp will run invisibly in the background (on the isolated Session 0 desktop). Therefore, you won't see Gulp's console window nor have access to text logged to the console.

    If lack of access to the console is a problem, you should capture Gulp's console output to a text file. To do so:

    • Switch to the Extras tab.

    • In the Capture output to this log file field, enter the full path to the text file that should record the console output.

    • If important, specify what should happen to the output file if it grows very large.

    Gulp Windows Service: Extras Tab

  8. We're done configuring Gulp as a Windows Service so click the Save button to record your settings.

    In a couple of seconds, an application called Gulp (or whatever you called it) will show up in the AlwaysUp window. It is not yet running though and the state will be "Stopped":

    Gulp Windows Service: Installed

  9. To start Gulp from AlwaysUp, choose Application > Start "Gulp".

    In a few seconds, the status will change to "Running" and Gulp will be working in the background:

    Gulp Windows Service: Running

    If you captured Gulp's console output to a file (step 7), please open the file and check the contents. Everything should be fine, as it was on our machine:

    Gulp Windows Service: Console text captured

  10. That's it! Next time your computer boots, Gulp will start up immediately, in the background, without anyone needing to log on. Please restart your PC now and test that everything works as expected after Windows returns to life.

    And please feel free to edit Gulp in AlwaysUp and explore the many other settings that may be appropriate for your environment. For example, send an email if Gulp stops, constrain Node.js and Gulp to a specific CPU, and much more.



Gulp not working properly as a Windows Service?

  • Consult the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a windows service.

  • From AlwaysUp, select Application > Report Activity > Today to bring up an HTML report detailing the interaction between AlwaysUp and Gulp. The AlwaysUp Event Log Messages page explains the messages that may appear.

  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we'll be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 15.5 New!

8.0 MB Installer
Our 12,000+ customers include...
Compatible with Windows 11 Compatible with Windows Server 2022 Compatible with Windows 10
Over 94,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 19+ years!