Skip to content

Prettier 3.0 TypeError: prettier.resolveConfig.sync is not a function

Problem Statement

When using ESLint with Prettier integration, you might encounter this error after updating to Prettier 3.0:

text
TypeError: prettier.resolveConfig.sync is not a function
Occurred while linting [file]
Rule: "prettier/prettier"

Typical symptoms include:

  • The error appears when running ESLint commands (npx eslint ...)
  • Occurs after upgrading to Prettier 3.0 while using eslint-plugin-prettier@4.x
  • Persists after deleting node_modules and reinstalling dependencies
  • Most common in projects using this configuration in package.json:
    json
    "prettier": "^3.0.0",
    "eslint-plugin-prettier": "^4.2.1"

The root cause is an API incompatibility between Prettier 3.0 and older versions of eslint-plugin-prettier. Prettier 3.0 removed the synchronous resolveConfig.sync method that the plugin relied on.

Note

This error only affects integrations using eslint-plugin-prettier. Other Prettier integrations may work differently.

Solutions

The official fix requires updating eslint-plugin-prettier to version 5.0 or newer, which adds support for Prettier 3.0's asynchronous API:

bash
npm install --save-dev eslint-plugin-prettier@5.0.0
bash
yarn add -D eslint-plugin-prettier@5.0.0

After installation, verify your package.json contains:

json
"eslint-plugin-prettier": "^5.0.0",

Key benefits:

  • Maintains Prettier 3.x features and improvements
  • Requires minimal configuration changes
  • Officially supported solution (GitHub Issue)

2. Downgrade Prettier to 2.8.x

If you can't immediately upgrade the plugin, downgrade Prettier to the latest 2.x version:

bash
npm install --save-dev prettier@2.8.8
bash
yarn add -D prettier@2.8.8

Ensure compatible plugin versions when downgrading:

json
"prettier": "^2.8.0",
"eslint-plugin-prettier": "^4.0.0" // Compatible with Prettier 2.x

Limitation

You'll miss out on Prettier 3.0 improvements and future updates

3. Verify Prettier Installation

Ensure prettier is actually installed in your project. Surprisingly, this is often overlooked when adding plugins:

bash
npm install --save-dev prettier@3.0.0
bash
yarn add -D prettier@3.0.0

Other tools in your formatting pipeline may also cause conflicts:

  • pretty-quick: Not compatible with Prettier 3.0 (last updated >2 years ago). Switch to lint-staged:
json
// package.json
"lint-staged": {
  "*.{js,jsx,ts,tsx,json,css,md}": [
    "prettier --write"
  ]
}
  • prettier-eslint: Update to v15+ for Prettier 3 support
  • CRA users: Downgrade to compatible versions:
json
"eslint": "^7.32.0",
"prettier": "^2.8.0",
"eslint-plugin-prettier": "^4.2.1"

Additional Configuration Tips

Verify Prettier Resolution

Add this test script to confirm Prettier can resolve configurations:

js
// test-prettier.js
import prettier from 'prettier';
console.log('Resolved Prettier config:', 
  await prettier.resolveConfig(process.cwd()));

Run with:

bash
node --no-warnings --loader=ts-node/esm test-prettier.js

ESLint Config Sample

Working .eslintrc.js configuration after fixes:

js
module.exports = {
  extends: [
    'plugin:prettier/recommended' // Order matters: should be last
  ],
  plugins: ['prettier'],
  rules: {
    'prettier/prettier': 'error'
  }
}

Best Practice

Place eslint-plugin-prettier last in your ESLint configuration extends array to override conflicting formatting rules.

Summary of Fixes

SolutionPrettier VersionPlugin VersionCommand
Recommended^3.0.0^5.0.0npm i -D eslint-plugin-prettier@5
Temporary fix^2.8.0^4.0.0npm i -D prettier@2.8.8
Ensure installed^3.0.0Any compatible versionnpm i -D prettier@3

Always remember to restart your IDE and ESLint server after making dependency changes to ensure new configurations are loaded.