gulp-nf-prettier
raw JSON → 3.0.0 verified Sat Apr 25 auth: no javascript
A Gulp plugin to format code using Prettier, forked from gulp-prettier with Netflix-specific requirements. Current stable version is 6.0.0 (pure ESM, Node 18+). Prettier is a peer dependency, allowing independent upgrades. Key differentiators: supports editorconfig, includes a `check` method for CI (errors on unformatted files), and offers options like `printWidth`, `parser`, `singleQuote`. Successor to v3.0.0 (Prettier v2) and v5.0.0 (Prettier v3). Alternative to gulp-prettier.
Common errors
error Cannot find module 'gulp-nf-prettier' ↓
cause gulp-nf-prettier is a scoped or private fork; may not be published on npm.
fix
Install from GitHub: npm install https://github.com/bhargavrpatel/gulp-prettier
error require() of ES Module not supported ↓
cause Using CommonJS require() with v6.0.0+ (pure ESM).
fix
Switch to import syntax or downgrade to v5.0.0.
error Error: Cannot find module 'prettier' ↓
cause Peer dependency prettier not installed.
fix
Install prettier: npm install prettier --save-dev
error TypeError: prettier is not a function ↓
cause Trying to call a non-existent named export prettier.check() or using wrong import style.
fix
Use default import: import prettier from 'gulp-nf-prettier'
Warnings
breaking Requires Node 18+. Dropped Node 12 and 14 in v5.0.0, Node 10 in v4.0.0. ↓
fix Upgrade Node.js to version 18 or later.
breaking Pure ESM since v6.0.0. CommonJS require() will throw. ↓
fix Use import syntax and ensure project is ESM (e.g., type: 'module' in package.json).
breaking Prettier upgrade to v3.0.0 in v5.0.0 introduced breaking changes in Prettier's API and defaults. ↓
fix Review Prettier 3.0 migration guide. Options like trailingComma may need updating.
breaking Upgrade to Prettier v2.0.0 in v3.0.0 dropped Node 4, 6, 8 support and included Prettier breaking changes. ↓
fix Ensure Node >=10 and review Prettier 2.0 breaking changes.
deprecated gulp-nf-prettier is a fork; original gulp-prettier may have different maintenance. ↓
fix Consider using the upstream gulp-prettier or other alternatives if Netflix-specific features aren't needed.
gotcha Prettier is a peer dependency; must be installed separately. ↓
fix Run npm install prettier --save-dev.
gotcha The 'check' option errors on unformatted files; may break builds in CI if not expecting errors. ↓
fix Set check: false or handle build errors appropriately.
Install
npm install gulp-nf-prettier yarn add gulp-nf-prettier pnpm add gulp-nf-prettier Imports
- default wrong
const prettier = require('gulp-nf-prettier')correctimport prettier from 'gulp-nf-prettier' - prettier wrong
import { prettier } from 'gulp-nf-prettier'correctimport prettier from 'gulp-nf-prettier' - gulp-nf-prettier options wrong
prettier.check({ parser: 'babel' })correctprettier({ check: true, parser: 'babel' })
Quickstart
import gulp from 'gulp';
import prettier from 'gulp-nf-prettier';
export function format() {
return gulp
.src('src/**/*.js', { base: './' })
.pipe(prettier({
printWidth: 100,
tabWidth: 2,
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: true,
parser: 'babel'
}))
.pipe(gulp.dest('./'));
}