Last updated: Mar 7, 2024
Reading timeยท3 min

node_modules and reinstall your dependenciesThe error "ESLint couldn't find the config "prettier" to extend from" occurs
when you forget to install the eslint-config-prettier module but extend from
it.
To solve the error, install the module as a development dependency before extending from it.
Oops! Something went wrong! :( ESLint: 8.40.0. ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/my-project/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js".
Open your terminal in your project's root directory (where your package.json
file is) and run the following command.
# with NPM npm install --save-dev eslint-config-prettier # or with YARN yarn add eslint-config-prettier --dev

Your linter might conflict with Prettier, so Prettier should only be used for code formatting and linters should only be used for code-quality concerns.
The eslint-config-prettier package turns off all rules that are unnecessary or might conflict with Prettier.
Make sure to add "prettier" to the extends array in your .eslintrc file.
{ "extends": [ "YOUR_OTHER_CONFIG_HERE", "prettier" ] }
The prettier config only turns rules off, so it should be used together with
some other config.
Make sure to replace the YOUR_OTHER_CONFIG_HERE placeholder with an actual
config you want to extend from.
prettier is the last entry in your extends array.If you use a .eslintrc.js file, your config would look similar to the
following.
module.exports = { "extends": [ "YOUR_OTHER_CONFIG_HERE", "prettier" ] };
Note that rules that are defined in the rules object in your ESLint config
always override rules that are defined in configs from the extends array.
Extending from prettier turns off a bunch of rules. Some of them are
documented in
this section
of the GitHub page of eslint-config-prettier.
If you get the error 'ESLint couldn't find the config
"prettier/@typescript-eslint"', you have to remove
prettier/@typescript-eslint from your extends array in .eslintrc.
prettier/@typescript-eslint has been removed from the eslint-config-prettier
package in version 8 as shown in the
package's Changelog page.
Open your .eslintrc, .eslintrc.js or .eslintrc.json file and remove
prettier/@typescript-eslint from your extends array.
{ "extends": [ "YOUR_OTHER_CONFIG_HERE", "prettier", // ๐๏ธ REMOVE THIS // "prettier/@typescript-eslint" ] }
In order for the eslint-config-prettier package to work, you just have to
extend from prettier now.
The following config is valid.
{ "extends": [ "prettier" ] }
prettier is the last entry in your extends array.And here is the .eslintrc.js (JavaScript) equivalent of the previous config.
module.exports = { "extends": [ "prettier" ] };
node_modules and reinstall your dependenciesIf the issue persists, try to delete your node_modules directory and reinstall
your dependencies.
If you are on macOS or Linux, run the following commands in bash or zsh.
# for macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐๏ธ clean npm cache npm cache clean --force # ๐๏ธ install packages npm install
If you are on Windows, run the following commands in CMD.
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐๏ธ clean npm cache npm cache clean --force # ๐๏ธ install packages npm install
If the issue persists, try to restart your development server and your code editor.
You can learn more about the related topics by checking out the following tutorials:
await inside a loop.eslint no-await-in-loop