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:
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_modulesand 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
1. Upgrade eslint-plugin-prettier to v5+ (Recommended)
The official fix requires updating eslint-plugin-prettier to version 5.0 or newer, which adds support for Prettier 3.0's asynchronous API:
npm install --save-dev eslint-plugin-prettier@5.0.0yarn add -D eslint-plugin-prettier@5.0.0After installation, verify your package.json contains:
"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:
npm install --save-dev prettier@2.8.8yarn add -D prettier@2.8.8Ensure compatible plugin versions when downgrading:
"prettier": "^2.8.0",
"eslint-plugin-prettier": "^4.0.0" // Compatible with Prettier 2.xLimitation
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:
npm install --save-dev prettier@3.0.0yarn add -D prettier@3.0.04. Update Related Tools (if applicable)
Other tools in your formatting pipeline may also cause conflicts:
pretty-quick: Not compatible with Prettier 3.0 (last updated >2 years ago). Switch tolint-staged:
// 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:
"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:
// test-prettier.js
import prettier from 'prettier';
console.log('Resolved Prettier config:',
await prettier.resolveConfig(process.cwd()));Run with:
node --no-warnings --loader=ts-node/esm test-prettier.jsESLint Config Sample
Working .eslintrc.js configuration after fixes:
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
| Solution | Prettier Version | Plugin Version | Command |
|---|---|---|---|
| Recommended | ^3.0.0 | ^5.0.0 | npm i -D eslint-plugin-prettier@5 |
| Temporary fix | ^2.8.0 | ^4.0.0 | npm i -D prettier@2.8.8 |
| Ensure installed | ^3.0.0 | Any compatible version | npm i -D prettier@3 |
Always remember to restart your IDE and ESLint server after making dependency changes to ensure new configurations are loaded.