Registry / devops / prettierr

prettierr

JSON →
library1.15.3-devjsnpmunverified

Prettier is an opinionated code formatter that supports JavaScript, TypeScript, CSS, JSON, Markdown, YAML, and more via plugins. Current stable version is 3.4.2, released monthly. It parses code and reprints it with its own rules, enforcing consistent style and handling line wrapping. Key differentiators: zero configuration, automatic formatting on save, editor integrations, and a vast plugin ecosystem. It is widely adopted in the JavaScript ecosystem.

npm install prettierr
INSTALL
IMPORT
SIG · PRETTIERR
P
prettierr
devopsjavascriptv1.15.3-dev
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.

format
import { format } from 'prettier'
const prettier = require('prettier'); prettier.format(source, options)
ESM import is recommended. CommonJS require is still supported but deprecated in newer versions.
check
import { check } from 'prettier'
const check = require('prettier').check
check type returns a boolean. ESM-only since v3? Actually both ESM and CJS work.
resolveConfig
import { resolveConfig } from 'prettier'
const { resolveConfig } = require('prettier')
resolveConfig is an async function. Await in ESM, no callback.
default
import prettier from 'prettier'
const prettier = require('prettier')
Default export in ESM is an object with format, check, etc.

Shows how to format a string of JavaScript code using Prettier API with custom options.

import { format } from 'prettier'; const source = `const hello = 'world'`; const formatted = await format(source, { parser: 'babel', semi: false, singleQuote: true }); console.log(formatted); // const hello = 'world'
Debug
Known issues
breakingPrettier 2.0 drops support for Node.js < 10 and changes default trailingComma to 'all' and arrowParens to 'always'.
fix
Update Node.js to >=10. Review formatting changes and possibly set trailingComma: 'es5' and arrowParens: 'avoid' in config.
affects: >=2.0.0
deprecatedThe --stdin and --write flags have changed in v2.0.
fix
Use --write to overwrite files and --check for CI. stdin is implicit.
affects: >=2.0.0
gotchaPrettier 1.x had a bug where --write with .prettierrc could cause infinite loops on some malformed files.
fix
Upgrade to v2+ or use --no-config.
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'prettier'
Prettier is not installed or the import path is wrong.
fix
Run 'npm install prettier' and ensure import is 'import { format } from 'prettier'' (no './' prefix).
Cannot find module './prettier' from '/path/to/file'
Using a relative import path instead of the package name.
fix
Change import to 'prettier' instead of './prettier'.
TypeError: prettier.format is not a function
Using a version < 2.0 where format is named 'format' but not exported? Actually it's same. Or using default import without destructuring.
fix
Use 'import { format } from 'prettier'' or 'import prettier from 'prettier'; prettier.format(...)'.
Error: Cannot find module 'prettier' while using require()
Prettier is not installed or the module path is incorrect.
fix
Install prettier via npm and use 'const prettier = require('prettier')'.
Upgrade
Version history
1.15.3-devlatest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
prettierr — npm install prettierr · libregistry