Registry /
devops / babel-plugin-generator-prettier
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
babelPluginGeneratorPrettier
✓ import babelPluginGeneratorPrettier from 'babel-plugin-generator-prettier'
✗ const babelPluginGeneratorPrettier = require('babel-plugin-generator-prettier')
Plugin is typically used without importing; configured in .babelrc or babel.config.js. If importing for programmatic use, use default import.
plugin
✓ plugins: ['generator-prettier']
✗ plugins: ['babel-plugin-generator-prettier']
In .babelrc or babel.config.js, the package is referenced by its short name (without 'babel-plugin-').
generatorOpts
✓ generatorOpts: { printWidth: 120 }
Prettier options are passed via the `generatorOpts` top-level key in Babel config, not inside the plugin config.
Configures the plugin in .babelrc to format output with Prettier using custom print width, semicolons, single quotes, trailing commas, and tab width.
// .babelrc
{
"plugins": ["generator-prettier"],
"generatorOpts": {
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2
}
}
// In your build script (if using Node API)
const babel = require('@babel/core');
babel.transformSync('const x = 1', {
plugins: ['generator-prettier'],
generatorOpts: {
printWidth: 80,
semi: true,
singleQuote: true,
trailingComma: 'all',
tabWidth: 2
}
});
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-generator-prettier'
The plugin is not installed or is listed incorrectly in Babel config.
fixRun `npm install babel-plugin-generator-prettier` and ensure the plugin name is correct (e.g., 'generator-prettier' in .babelrc).
Error: Plugin generator-prettier requires Babel 7
The project uses Babel 6.
fixUpgrade to Babel 7: `npm install @babel/core @babel/cli` and update config files.
TypeError: prettier.format is not a function
Incompatible Prettier version (pre-v2 API). The plugin expects the modern prettier.format function.
fixInstall Prettier v2+: `npm install prettier@2`.
Audit
Dependencies
@babel/corerequiredBabel plugin requires Babel 7 as host
prettierrequiredUsed to format transformed code