Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Gulp stops with Cannot find module 'gulp-util'

ErrorError: Cannot find module 'gulp-util'

Short answer

gulp-util was deprecated and its functions were split into small packages, so a gulpfile or plugin that still requires it breaks. Find who requires it with npm explain, then replace each gutil call with the package the maintainers list, or update or replace the plugin that depends on it.

  • Applies to Node.js 22, npm 10, gulp 4 and 5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the Require stack under the error. If it starts with your gulpfile.js, the call is yours; if it lists a path inside node_modules, a plugin needs it.

    npx gulp 2>&1 | head -20
    grep -n "gulp-util" gulpfile.js package.json
  2. 2Match what you see, then jump to its fix

    1. 1The first line of the Require stack is your own gulpfile.js, and the grep finds gulp-util there.Your gulpfile still requires gulp-utilFix
    2. 2The Require stack points at a file such as node_modules/gulp-something/index.js.A gulp plugin in node_modules depends on gulp-utilFix

What does the error look like?

  • Error: Cannot find module 'gulp-util'
  • Require stack: gulpfile.js

Cause 1 of 2

Your gulpfile still requires gulp-util

1Check

List which gutil functions the file uses, such as gutil.log, gutil.colors or gutil.PluginError.

grep -n "gutil\." gulpfile.js

2Fix

The module's README says it is deprecated and lists replacements: gutil.log becomes fancy-log, gutil.colors becomes ansi-colors, gutil.PluginError becomes plugin-error, gutil.env becomes minimist, and gutil.noop becomes through2. Install the packages you use and change the requires.

npm install --save-dev fancy-log ansi-colors plugin-error

// gulpfile.js
const log = require('fancy-log');
const colors = require('ansi-colors');
log(colors.green('build done'));

3Verify

Run the gulp task again; the error should be gone.

npx gulp

Confirmed by github.com

Did this fix it?

Cause 2 of 2

A gulp plugin in node_modules depends on gulp-util

1Check

Ask npm why the package is in the tree, then find the plugin that requires it.

npm explain gulp-util

2Fix

gulp-util is deprecated, so a plugin that still needs it is out of date. Update that plugin to a release that dropped gulp-util, or swap it for another plugin that does the same job.

npm explain gulp-util
npm install --save-dev <plugin-name>@latest

3Verify

Run npm explain again; it should report that gulp-util is not found, then run gulp.

npm explain gulp-util
npx gulp

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Do not add gulp-util to new gulpfiles; use the single-purpose replacement packages.
  • Check plugins for recent releases before adopting them.
  • Commit package-lock.json so everyone installs the same tree.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.