Gulp stops with Cannot find module 'gulp-util'
Error: 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.
Fix it fast
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.json2Match what you see, then jump to its fix
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.js2Fix
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 gulpConfirmed by github.com
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-util2Fix
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>@latest3Verify
Run npm explain again; it should report that gulp-util is not found, then run gulp.
npm explain gulp-util
npx gulpConfirmed by docs.npmjs.com
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
Gulp crashes at start with "primordials is not defined"
const { Math, Object, Reflect } = primordials;
This error means an old copy of graceful-fs, pulled in by Gulp 3, is running on a Node.js version it cannot work with.
3 causes, each with a fixBack 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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix