{"id":13284,"library":"gulp","title":"Gulp Build System","description":"Gulp is a powerful, streaming build system designed to automate repetitive and time-consuming tasks in development workflows. It operates by piping files through a series of small, single-purpose plugins, treating files as streams. The current stable version is 5.0.1, with releases typically occurring as needed for bug fixes, performance improvements, or new features rather than on a fixed schedule. Key differentiators include its code-over-configuration philosophy, minimal API surface, and functional approach, which encourages writing small, focused tasks that compose together. It's platform-agnostic, integrating with various IDEs and usable across PHP, .NET, Node.js, Java, and other environments, boasting a strong ecosystem with over 3000 curated plugins available via npm. The emphasis on streams and direct code manipulation provides a high degree of control and flexibility.","status":"active","version":"5.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/gulpjs/gulp","tags":["javascript","build","stream","system","make","tool","asset","pipeline","series"],"install":[{"cmd":"npm install gulp","lang":"bash","label":"npm"},{"cmd":"yarn add gulp","lang":"bash","label":"yarn"},{"cmd":"pnpm add gulp","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Commonly used for cleaning directories in gulpfiles, as demonstrated in official examples.","package":"del","optional":false},{"reason":"Provides the command-line interface to run gulp tasks; typically installed globally or as a dev dependency.","package":"gulp-cli","optional":true}],"imports":[{"note":"Preferred modern ESM import style for named exports when using `type: 'module'` in package.json or `.mjs` files.","wrong":"const { src, dest, series, parallel, watch } = require('gulp');","symbol":"{ src, dest, series, parallel, watch }","correct":"import { src, dest, series, parallel, watch } from 'gulp';"},{"note":"ESM default import for the entire gulp API, less common as specific functions are usually destructured.","wrong":"const gulp = require('gulp');","symbol":"gulp","correct":"import gulp from 'gulp';"},{"note":"CommonJS `require` syntax, still widely used in older projects or when `type: 'module'` is not specified in package.json. Will throw errors if used in an ESM context.","wrong":"import gulp from 'gulp';","symbol":"gulp","correct":"const gulp = require('gulp');"}],"quickstart":{"code":"import { src, dest, watch, series, parallel } from 'gulp';\nimport less from 'gulp-less';\nimport babel from 'gulp-babel';\nimport concat from 'gulp-concat';\nimport uglify from 'gulp-uglify';\nimport rename from 'gulp-rename';\nimport cleanCSS from 'gulp-clean-css';\nimport del from 'del';\n\nconst paths = {\n  styles: {\n    src: 'src/styles/**/*.less',\n    dest: 'assets/styles/'\n  },\n  scripts: {\n    src: 'src/scripts/**/*.js',\n    dest: 'assets/scripts/'\n  }\n};\n\nasync function clean() {\n  return del(['assets']);\n}\n\nfunction styles() {\n  return src(paths.styles.src)\n    .pipe(less())\n    .pipe(cleanCSS())\n    .pipe(rename({\n      basename: 'main',\n      suffix: '.min'\n    }))\n    .pipe(dest(paths.styles.dest));\n}\n\nfunction scripts() {\n  return src(paths.scripts.src, { sourcemaps: true })\n    .pipe(babel({ presets: ['@babel/preset-env'] })) // Ensure @babel/preset-env is installed\n    .pipe(uglify())\n    .pipe(concat('main.min.js'))\n    .pipe(dest(paths.scripts.dest));\n}\n\nfunction watchFiles() {\n  watch(paths.scripts.src, scripts);\n  watch(paths.styles.src, styles);\n}\n\nexport const cleanTask = clean;\nexport const stylesTask = styles;\nexport const scriptsTask = scripts;\nexport const watchTask = watchFiles;\nexport default series(clean, parallel(styles, scripts));\n","lang":"javascript","description":"This quickstart `gulpfile.mjs` demonstrates an asynchronous cleanup task, followed by parallel compilation, minification, and concatenation of Less styles and ESNext JavaScript, with a watch task for continuous development. It showcases modern ESM syntax for Gulp 5."},"warnings":[{"fix":"Upgrade your Node.js environment to version 10.13.0 or higher. For best compatibility, use a current LTS release.","message":"Gulp v5 dropped support for Node.js versions older than 10.13. Projects on unsupported Node.js versions will fail to run Gulp 5 tasks.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Review tasks that read or write files to ensure they correctly handle file encodings. Explicitly specify encoding options where necessary, especially for non-UTF-8 files.","message":"In Gulp v5, the default stream encoding was standardized to UTF-8. This may affect tasks that process files with different encodings if not explicitly handled.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Verify existing glob patterns, especially complex ones or those relying on specific ordering. Adjust patterns if `anymatch` behavior differs from previous implementations or if ordered glob assumptions were made.","message":"Gulp v5 standardized on the `anymatch` library for globbing paths, ensuring consistent behavior between `src` and `watch`. Additionally, support for ordered globs was removed.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Replace `gulp-util` functionalities with standard Node.js modules or dedicated, modern npm packages. Many plugins that depended on `gulp-util` have been updated or have modern alternatives.","message":"Gulp v4 removed the `gulp-util` package, a utility library commonly used in older gulpfiles and plugins. This means direct usage of `gulp-util` will result in errors.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"For ES Modules context, use `import` statements. If you need CommonJS `require`, ensure your gulpfile is `.js` and your `package.json` does not specify `\"type\": \"module\"`.","message":"Using `require()` in a Gulpfile named `.mjs` or when `type: \"module\"` is set in `package.json` will result in `ReferenceError: require is not defined`.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change all `require()` calls to `import` statements. For example, `const gulp = require('gulp');` becomes `import gulp from 'gulp';` or `import { src, dest } from 'gulp';`.","cause":"Attempting to use CommonJS `require()` syntax within an ES Module (ESM) file context, such as a `gulpfile.mjs` or a `.js` file where `\"type\": \"module\"` is set in `package.json`.","error":"ReferenceError: require is not defined"},{"fix":"Ensure that your task functions are explicitly exported. For example, `function myTask() {...}` should be `exports.myTask = myTask;` in CommonJS or `export const myTask = myTask;` in ESM, or included in an exported `series` or `parallel` composition.","cause":"A task function defined in the gulpfile was not exported correctly, preventing Gulp from discovering or executing it.","error":"The following tasks did not complete: default. Did you forget to export them?"},{"fix":"Install the missing plugin using `npm install --save-dev gulp-plugin-name` or `yarn add --dev gulp-plugin-name`. Double-check the spelling of the module name.","cause":"A Gulp plugin is being `require()`d or `import`ed in the gulpfile but has not been installed via npm, or there's a typo in the package name.","error":"Error: Cannot find module 'gulp-plugin-name'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"gulp","cli_version":null}