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.
preset (via package.json)
✓ In package.json: "prettier": "prettier-preset"
✗ Using .prettierrc.js with `module.exports = require('prettier-preset')` (not supported)
This package provides a JSON config, not a module. Specify the package name directly in package.json under prettier key.
Default config (require)
✓ In .prettierrc.js: module.exports = 'prettier-preset';
✗ module.exports = require('prettier-preset'); // exports string not object
Since v1.0, the preset is a string reference, not an object. Use string literal in module.exports.
Import for programmatic use
✓ const preset = require('prettier-preset'); // returns string 'prettier-preset'
✗ import preset from 'prettier-preset'; // ESM not supported
Package is CJS only; ESM import will fail. Use require() if accessing programmatically, but the value is just the preset name.
Install the preset and configure Prettier in package.json; then run Prettier.
// Install
$ yarn add --dev prettier prettier-preset
// package.json
{
"name": "my-project",
"version": "1.0.0",
"prettier": "prettier-preset"
}
// Then run prettier on files
$ npx prettier --write src/
Errors
Common errors & fixes
Error: Invalid configuration file '.prettierrc.js': Expected an object but got a string.
Using module.exports = require('prettier-preset') which yields the string 'prettier-preset'.
fixUse module.exports = 'prettier-preset'; (string literal) or set "prettier": "prettier-preset" in package.json.
Cannot find module 'prettier-preset'
prettier-preset is not installed or not in node_modules.
fixRun npm install --save-dev prettier-preset (or yarn add --dev prettier-preset).
Unexpected token export (or similar ESM import error)
Attempting to import preset using ES modules import (e.g., import preset from 'prettier-preset'). Package is CJS-only.
fixUse require('prettier-preset') for programmatic access, or use the package.json string method. Audit
Dependencies
prettieroptionalpeer dependency to provide formatter