Registry / devops / prettier-resolver

prettier-resolver

JSON →
library1.2.2jsnpmunverified

Prettier is an opinionated code formatter that supports JavaScript, TypeScript, CSS, HTML, GraphQL, Markdown, and more. Current stable version is 3.x (npm package name 'prettier', not 'prettier-resolver'). Prettier is actively maintained with frequent releases. It differs from other formatters by being opinionated (few options), rewriting entire AST, and integrating into editors, pre-commit hooks, and CI. Available as CLI and API; ships as ESM-only since v3, requires Node >=18.

npm install prettier-resolver
INSTALL
IMPORT
SIG · PRETTIER-RESOLVER
P
prettier-resolver
devopsjavascriptv1.2.2
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 * as prettier from 'prettier'
import prettier from 'prettier'
Use namespace import for all exports; no default export since v3.
format
import { format } from 'prettier'
const { format } = require('prettier')
Named exports available; CommonJS require not supported in v3.
resolveConfig
import { resolveConfig } from 'prettier'
Works with ESM; config resolution is async.
prettier (CLI)
npx prettier --write .
prettier --write .
CLI is invoked via npx or global install; path-based execution is common.
PrettierOptions
import type { Options } from 'prettier'
import { Options } from 'prettier'
Use type import for TypeScript options; Options type exists since v2.

Demonstrates using Prettier's format() API to format JavaScript code with custom options.

import { format } from 'prettier'; const code = `foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());`; const formatted = await format(code, { parser: 'babel', semi: true, singleQuote: true, tabWidth: 2, }); console.log(formatted);
Debug
Known issues
breakingPrettier v3 drops CommonJS support; require() will not work.
fix
Switch to ESM imports (import { format } from 'prettier') or use dynamic import().
affects: >=3.0.0
breakingNode.js >=18 required as of v3; older Node versions cause errors.
fix
Upgrade Node.js to version 18 or later.
affects: >=3.0.0
gotchaFormatting with 'resolveConfig' returns null if no config found; must handle null case.
fix
Use `const config = (await resolveConfig(filePath)) ?? {};` to avoid undefined errors.
affects: >=2.0.0
deprecatedThe '--no-semi' CLI flag is deprecated in favor of '--semi false'.
fix
Use '--semi false' instead of '--no-semi'.
affects: >=2.3.0
gotchaUsing prettier-plugin-svelte or prettier-plugin-tailwindcss may conflict with each other; order matters.
fix
List plugins in order of application (e.g., prettier-plugin-svelte first).
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'prettier'
Prettier not installed or used via CommonJS in v3.
fix
Run `npm install prettier@latest` and use ESM import syntax.
TypeError: prettier.format is not a function
Incorrect import style; default import does not exist in v3.
fix
Use `import { format } from 'prettier'` instead of `import prettier from 'prettier'`.
Error: Cannot find module 'prettier/package.json'
Using older require() path that is removed in v3.
fix
Use `import { format } from 'prettier'` or update to v2 for CommonJS support.
Error: Couldn't resolve parser 'babel'. Plugins don't seem to be installed.
Missing parser plugin (e.g., @prettier/plugin-babel).
fix
Install parser: `npm install --save-dev @prettier/plugin-babel` and add to config.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
prettier-resolver — npm install prettier-resolver · libregistry