Registry / testing / prettier-ts

prettier-ts

JSON →
library1.17.1-2jsnpmunverified

Prettier is an opinionated code formatter that supports JavaScript, TypeScript, CSS, HTML, GraphQL, Markdown, YAML, and many other languages via plugins. The current stable version is 3.8.3 (as of early 2025). It enforces a consistent style by parsing code and re-printing it with its own rules, taking maximum line length into account. Key differentiators: it eliminates debates over code style by being opinionated, integrates with editors and CI via pre-commit hooks, and supports a wide ecosystem of plugins. Released under MIT license, available as an npm package with weekly downloads exceeding 50 million.

npm install prettier-ts
INSTALL
IMPORT
SIG · PRETTIER-TS
P
prettier-ts
testingjavascriptv1.17.1-2
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.

prettier
import * as prettier from 'prettier'
const prettier = require('prettier')
Prettier v3 is ESM-only. When using CommonJS, use dynamic import: const prettier = await import('prettier'). For older versions (v2), require() works.
format
import { format } from 'prettier'
const format = require('prettier').format
Named export for formatting a string. In CommonJS, use destructuring from dynamic import.
resolveConfig
import { resolveConfig } from 'prettier'
Resolves configuration from a file path. Returns a config object or null.
check
import { check } from 'prettier'
import { check } from 'prettier/check'
check is a named export from 'prettier' since v3, not a separate module.

Demonstrates async formatting with config resolution. Parses source as JavaScript and applies Prettier rules.

import { format, resolveConfig } from 'prettier'; async function formatCode(code, filepath) { const options = await resolveConfig(filepath); const formatted = await format(code, { ...options, parser: 'babel', filepath }); console.log(formatted); } formatCode('const x = { foo: "bar" }', 'example.js');
prettier --version
Debug
Known issues
breakingPrettier v3 drops Node.js 12 support, requires Node >= 14.17.0.
fix
Upgrade Node.js to version 14.17.0 or higher.
affects: >=3.0.0
breakingPrettier v3 removes the 'typescript' parser alias; use 'babel-ts' or 'typescript' explicitly.
fix
Change parser option from 'typescript' to 'babel-ts' or 'typescript' (still valid but no longer an alias).
affects: >=3.0.0
deprecatedUse of `prettier.standalone` standalone build is deprecated; use `prettier/standalone` module instead.
fix
Replace import 'prettier/standalone' with 'prettier/standalone' (note: no change in path, but the old global isn't available).
affects: >=3.0.0
gotchaPrettier v3 runs asynchronously; use `await format()` not `format()` synchronously.
fix
Ensure all calls to prettier.format are awaited.
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'prettier/standalone'
The standalone module path has changed; or the package is not installed.
fix
Install prettier: npm install prettier. Use import 'prettier/standalone' if using the standalone build.
TypeError: format is not a function
prettier.format is not a function when using older CommonJS require without destructuring or dynamic import.
fix
Use dynamic import: import('prettier').then(p => p.format(...)) or switch to ESM.
Resolution failed. No such file or directory: .prettierrc
resolveConfig is called without a filepath or the config file does not exist.
fix
Provide a valid file path to resolveConfig from the project root.
Prettier 2.x vs 3.x: unknown option '--no-semi'
In Prettier v3, CLI flags changed; --no-semi is replaced by --semi false.
fix
Use --semi false instead of --no-semi.
Upgrade
Version history
1.17.1-2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
prettier-ts — npm install prettier-ts · libregistry