Registry / devops / gulp-prettier

gulp-prettier

JSON →
library6.0.0jsnpmunverified

A Gulp plugin to format files with Prettier. Current stable version is 6.0.0, released November 2023. This plugin integrates Prettier into Gulp build pipelines, allowing automatic code formatting during development or as a CI check via `prettier.check()`. Key differentiators: simple API mirroring Prettier's options, supports EditorConfig, and the `check` method for CI validation. Since v6.0.0, it is pure ESM and requires Node 18. Prior v5.0.0 upgraded Prettier to v3.0.0. It is a direct replacement for manually calling Prettier in Gulp tasks.

npm install gulp-prettier
INSTALL
IMPORT
SIG · GULP-PRETTIER
G
gulp-prettier
devopsjavascriptv6.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (plugin function)
import prettier from 'gulp-prettier'
const prettier = require('gulp-prettier')
ESM-only since v6.0.0; require() will fail.
type imports (TypeScript)
import type { PrettierOptions } from 'gulp-prettier'
If you need the options type from Prettier, import from 'prettier' directly.
CommonJS workaround
import prettier from 'gulp-prettier'; // within an ES module
const prettier = require('gulp-prettier');
In v6, this package is ESM-only. Use dynamic import or set "type": "module" in package.json.

Defines two Gulp tasks: 'format' to format JavaScript files using Prettier with options, and 'check' to validate formatting in CI.

import gulp from 'gulp'; import prettier from 'gulp-prettier'; export function format() { return gulp.src('src/**/*.js') .pipe(prettier({ singleQuote: true, trailingComma: 'all' })) .pipe(gulp.dest('dist')); } export function check() { return gulp.src('dist/**/*.js') .pipe(prettier.check({ singleQuote: true })); }
Debug
Known issues
breakingv6.0.0 moved to pure ESM and requires Node >=18. CommonJS require() no longer works.
fix
Switch to ESM imports (import prettier from 'gulp-prettier') and ensure Node >=18.
affects: >=6.0.0
breakingv5.0.0 upgraded Prettier to v3.0.0, which has breaking changes in its API and options.
fix
Review Prettier v3 changelog for option changes; update your Prettier options accordingly.
affects: >=5.0.0 <6.0.0
breakingv4.0.0 dropped Node 10 support.
fix
Upgrade Node to >=12 (or later).
affects: >=4.0.0 <5.0.0
breakingv3.0.0 dropped Node 4,6,8 and upgraded Prettier to v2.0.0.
fix
Use Node >=10 and update Prettier options for v2 changes.
affects: >=3.0.0 <4.0.0
gotchaThe 'check' method throws an error if files are not formatted, which can break Gulp watch tasks. Use it only in CI or as a final validation step.
fix
Wrap in try/catch or use separate CI-only task.
affects: >=2.1.0
deprecatedOptions like 'singleQuote' and 'trailingComma' are part of Prettier's options and may change in future Prettier versions.
fix
Consult Prettier documentation for valid options; use .prettierrc file to share config.
affects: all
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
Using CommonJS require() on a package that is pure ESM (v6+).
fix
Switch to import statement: import prettier from 'gulp-prettier'; or use dynamic import().
Error: Cannot find module 'gulp-prettier'
gulp-prettier not installed or not in node_modules.
fix
Run: npm install gulp-prettier --save-dev
TypeError: prettier is not a function
Incorrect import pattern; importing default incorrectly.
fix
Use: import prettier from 'gulp-prettier';
Error: No files matched pattern: ... (or similar Gulp error)
glob pattern in gulp.src() matches no files.
fix
Ensure src pattern is correct and files exist.
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies
prettieroptionalPeer dependency for formatting; must be installed separately.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-prettier — npm install gulp-prettier · libregistry