ESLint couldn't find the config 'prettier' to extend from

avatar
Borislav Hadzhiev

Last updated: Mar 7, 2024
3 min

banner

# Table of Contents

  1. ESLint couldn't find the config 'prettier' to extend from
  2. ESLint couldn't find the config "prettier/@typescript-eslint"
  3. Delete your node_modules and reinstall your dependencies

# ESLint couldn't find the config 'prettier' to extend from

The 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.

shell
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.

shell
# with NPM npm install --save-dev eslint-config-prettier # or with YARN yarn add eslint-config-prettier --dev

install eslint config prettier

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.

.eslintrc
{ "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.

Also, ensure that prettier is the last entry in your extends array.

If you use a .eslintrc.js file, your config would look similar to the following.

.eslintrc.js
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.

# ESLint couldn't find the config "prettier/@typescript-eslint"

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.

.eslintrc
{ "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.

.eslintrc
{ "extends": [ "prettier" ] }
Ensure that prettier is the last entry in your extends array.

And here is the .eslintrc.js (JavaScript) equivalent of the previous config.

.eslintrc.js
module.exports = { "extends": [ "prettier" ] };

# Delete your node_modules and reinstall your dependencies

If 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.

shell
# 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.

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.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev