Registry / devops / pretierr

pretierr

JSON →
library3.3.3jsnpmunverified

Prettier is an opinionated code formatter that enforces a consistent style by parsing code and reprinting it with own rules. Version 3.3.3 (stable) requires Node >=14. It supports JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, YAML, and many more via plugins. Released monthly, it runs in editors, pre-commit hooks, and CI. Its key differentiator vs alternatives (ESLint, dprint) is that it reformats entire files deterministically with minimal configuration.

npm install pretierr
INSTALL
IMPORT
SIG · PRETIERR
P
pretierr
devopsjavascriptv3.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

prettier
import prettier from 'prettier'
const prettier = require('prettier')
ESM default import since v3; CJS require still works.
format
import { format } from 'prettier'
const { format } = require('prettier')
Named export available in ESM and CJS.
resolveConfig
import { resolveConfig } from 'prettier'
const resolveConfig = require('prettier').resolveConfig
Use named import for best tree-shaking.
getFileInfo
import { getFileInfo } from 'prettier'
Available since v2.
TypeScript types
import type { Options, Config } from 'prettier'
Types are built-in; no need for @types/prettier.

Demonstrates programmatic formatting with async/await, parser choice, and options (semicolons and quotes).

import prettier from 'prettier'; const code = `const foo = 'bar';`; const formatted = await prettier.format(code, { parser: 'babel', semi: false, singleQuote: true }); console.log(formatted); // Output: const foo = 'bar'
Debug
Known issues
breakingPrettier v3 changed default trailingComma from 'none' to 'all' (ES5).
fix
Add trailingComma: 'none' to config if you want old behavior.
affects: >=3.0.0 <3.0.0
breakingPrettier v3 deprecated --stdin-filepath in favor of --stdin-filepath is replaced by --stdin-filepath?
fix
Use --stdin-filepath as before; no change.
affects: >=3.0.0
breakingNode.js 10 and 12 no longer supported.
fix
Upgrade Node to >=14.
affects: >=3.0.0
deprecatedThe 'parser' option as a string is deprecated; pass an object.
fix
Use parser: 'babel' instead of parser: 'babylon'.
affects: >=2.3.0
gotchaPrettier formatting may change output length due to line wrapping; avoid using format as a linter.
fix
Use --check or --list-different in CI to verify formatting.
affects: >=1.0.0
gotchaPrettier respects .editorconfig but only for indent_style and indent_size.
fix
Set prettier options explicitly in .prettierrc if editorconfig values conflict.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'prettier'
Package not installed or not resolveable.
fix
Run npm install prettier --save-dev
Error: No parser could be inferred for file 'foo.jsx'
File extension not recognized or parser not set.
fix
Specify parser: 'babel' or install plugin for the language.
TypeError: prettier.format is not a function
Using CommonJS require incorrectly; importing default in ESM context.
fix
Use import prettier from 'prettier' or const prettier = require('prettier').default
Error: Invalid configuration file `.prettierrc`: JSON Error
Syntax error in .prettierrc JSON.
fix
Validate JSON using a linter or use .prettierrc.yaml
Upgrade
Version history
3.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
pretierr — npm install pretierr · libregistry