Guides 11792 Published by

The guide walks you through installing Gulp.js on Ubuntu 22.04 by first updating Node and npm to a recent version from NodeSource. After verifying the versions, it shows how to globally install the gulp-cli package so the gulp command can be used anywhere in the system. It then recommends creating a fresh project directory, initializing npm, installing Gulp locally, and writing a minimal gulpfile that copies HTML files from src to dist as a practical example. The post finishes with common pitfalls—such as permission issues, broken symlinks, or version mismatches—and tips for troubleshooting them before launching your first task.



How to Install Gulp.js on Ubuntu 22.04 LTS

If you’re wrestling with a front‑end build that feels more like a circus than a workflow, gulp can bring the order back. Here’s the straight‑up way to get it running on Ubuntu 22.04 LTS.

Make Sure Node and npm Are Up‑to‑Date

You’ll need at least Node 12 for gulp 4, but I’m going with Node 18 from NodeSource because it ships with a newer npm that plays nicely with the latest packages.

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

After installation check the versions:

node --version   # Expect v18.x.x
npm --version    # Should be 9.x or newer

Why bother? Gulp’s internal tooling is very picky about Node’s API surface. If you run an old npm, you’ll get silent failures when you try to install gulp.

Install the Global Gulp CLI
sudo npm install -g gulp-cli
gulp --version   # Should show 4.x.x

The global CLI lets you invoke `gulp` from anywhere. It’s not a pain, but if it hangs or refuses to run after you’ve installed it, double‑check that `/usr/local/bin` is in your PATH.

Create a Sample Project (Optional but Recommended)
mkdir gulp-demo && cd gulp-demo
npm init -y
npm install --save-dev gulp

Now add the minimal gulpfile:

// gulpfile.js
const { src, dest, series } = require('gulp');

function copy() {
  return src('src/*.html')
    .pipe(dest('dist'));
}

exports.default = series(copy);

Why set up a fresh folder? You’ll see how gulp interacts with `node_modules` and avoid the “module not found” errors that pop up when you try to run gulp from an unrelated project.

Run Your First Task
mkdir src && echo "<p>Hello, Gulp!</p>" > src/index.html
gulp   # Should copy index.html to dist/

If it prints “Hello, World!” instead of the task output, you probably forgot `npm install --save-dev gulp` or the file name is off.

Common Pitfalls on Ubuntu 22.04
  • Permission errors – If `npm install -g` throws EACCES, use sudo or set a different prefix via `~/.npmrc`.
  • Broken symlinks after an upgrade – Running `sudo npm rebuild` sometimes fixes gulp‑cli’s broken link to Node.
  • Conflicting local vs. global versions – Keep the project’s local gulp (`node_modules/.bin/gulp`) in sync with the CLI by running `npm install --save-dev gulp-cli` inside each repo.
Wrap It Up

That’s all there is to it. Once you have node, npm, and gulp‑cli on your Ubuntu 22.04 machine, you can spin up a full build pipeline in minutes instead of chasing elusive errors.