Registry / devops / grunt-prettier

grunt-prettier

JSON →
library2.2.0jsnpmunverified

Grunt plugin to run Prettier on your files. Integrates the Prettier code formatter into Grunt workflows. Current stable version is 2.2.0, released with support for Prettier v2 and config overrides. Release cadence is irregular. Differentiates from running Prettier via CLI by providing a Grunt task that supports multiple target configurations, file-to-file formatting, concatenation with formatting, and in-place overwriting. Options can be specified in task config or .prettierrc, merged with defaults.

npm install grunt-prettier
INSTALL
IMPORT
SIG · GRUNT-PRETTIER
G
grunt-prettier
devopsjavascriptv2.2.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.

grunt-prettier
grunt.loadNpmTasks('grunt-prettier');
grunt.loadNpmTasks('grunt-prettier'); (no wrong pattern, but note: must be called after installing)
CommonJS require pattern is used in Gruntfile; the plugin registers a 'prettier' task.
prettier
const prettier = require('prettier');
import prettier from 'prettier'; // ESM not supported in Node<14
Prettier is a peer dependency; not directly imported but used internally.
grunt
const grunt = require('grunt');
Grunt is the task runner; plugin is loaded via loadNpmTasks.

Shows minimal Gruntfile config to format JavaScript files with Prettier, including loading the plugin and running the default task.

// Install: npm install grunt grunt-prettier prettier --save-dev // Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ prettier: { options: { singleQuote: true, useTabs: false }, files: { // Format all JS files in src/ and write back src: ['src/**/*.js'] } } }); grunt.loadNpmTasks('grunt-prettier'); grunt.registerTask('default', ['prettier']); };
Debug
Known issues
breakingVersion 2.0 updated prettier to v2, which includes breaking changes (e.g., trailingComma default changed).
fix
Review prettier v2 changelog and update your options accordingly.
affects: >=2.0.0 <3.0.0
gotchaConfig overrides only work in .prettierrc, not in the Grunt task config.
fix
Specify overrides in a .prettierrc file adjacent to your Gruntfile.
affects: >=0.0.0
gotchaThe 'dest' format concatenates files before formatting; 'src' format overwrites in place.
fix
Use 'src' for in-place formatting; use 'files' mapping for file-to-file or concat+format.
affects: >=0.0.0
deprecatedNode.js >=10 required; older versions may not work with recent prettier.
fix
Upgrade Node to at least 10.0.0.
affects: >=2.0.0
Errors
Common errors & fixes
Warning: Task "prettier" not found.
grunt.loadNpmTasks('grunt-prettier') not called or plugin not installed.
fix
Ensure you run npm install grunt-prettier --save-dev and add grunt.loadNpmTasks('grunt-prettier') in Gruntfile.
Cannot find module 'prettier'
Prettier not installed as a peer dependency.
fix
Run: npm install prettier --save-dev
Fatal error: unable to format files
Incorrect file configuration (missing 'src' or 'files' property).
fix
Define either files.src (array of globs) or files mapping (source to dest).
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; the plugin runs Prettier for formatting.
gruntrequiredPeer dependency; Grunt is required.
Agent activity
6 hits · last 30 days
node
6
Resources
grunt-prettier — npm install grunt-prettier · libregistry