|
| 1 | +--- |
| 2 | +title: ESLint couldn't find the config … to extend from |
| 3 | +eleventyNavigation: |
| 4 | + key: couldn't find the config to extend from |
| 5 | + parent: troubleshooting |
| 6 | + title: ESLint couldn't find the config … to extend from |
| 7 | +--- |
| 8 | + |
| 9 | +## Symptoms |
| 10 | + |
| 11 | +When using the [legacy ESLint config system](../configure/configuration-files-deprecated), you may see this error running ESLint after installing dependencies: |
| 12 | + |
| 13 | +```plaintext |
| 14 | +ESLint couldn't find the config "${configName}" to extend from. Please check that the name of the config is correct. |
| 15 | +
|
| 16 | +The config "${configName}" was referenced from the config file in "${importerName}". |
| 17 | +``` |
| 18 | + |
| 19 | +## Cause |
| 20 | + |
| 21 | +ESLint configuration files specify shareable configs by their package name in the `extends` array. |
| 22 | +That package name is passed to the Node.js `require()`, which looks up the package under local `node_modules/` directories. |
| 23 | +For example, the following ESLint config will first try to load a module located at `node_modules/eslint-config-yours`: |
| 24 | + |
| 25 | +```js |
| 26 | +module.exports = { |
| 27 | + extends: ["eslint-config-yours"], |
| 28 | +}; |
| 29 | +``` |
| 30 | + |
| 31 | +The error is output when you attempt to extend from a configuration and the package for that configuration is not found in any searched `node_modules/`. |
| 32 | + |
| 33 | +Common reasons for this occurring include: |
| 34 | + |
| 35 | +* Not running `npm install` or the equivalent package manager command |
| 36 | +* Mistyping the case-sensitive name of the package and/or configuration |
| 37 | + |
| 38 | +### Config Name Variations |
| 39 | + |
| 40 | +Note that ESLint supports several config name formats: |
| 41 | + |
| 42 | +* The `eslint-config-` config name prefix may be omitted for brevity, e.g. `extends: ["yours"]` |
| 43 | + * [`@` npm scoped packages](https://docs.npmjs.com/cli/v10/using-npm/scope) put the `eslint-config-` prefix after the org scope, e.g. `extends: ["@org/yours"]` to load from `@org/eslint-config-yours` |
| 44 | +* A `plugin:` prefix indicates a config is loaded from a shared plugin, e.g. `extends: [plugin:yours/recommended]` to load from `eslint-plugin-yours` |
| 45 | + |
| 46 | +## Resolution |
| 47 | + |
| 48 | +Common resolutions for this issue include: |
| 49 | + |
| 50 | +* Upgrading all versions of all packages to their latest version |
| 51 | +* Adding the config as a `devDependency` in your `package.json` |
| 52 | +* Running `npm install` or the equivalent package manager command |
| 53 | +* Checking that the name in your config file matches the name of the config package |
| 54 | + |
| 55 | +## Resources |
| 56 | + |
| 57 | +For more information, see: |
| 58 | + |
| 59 | +* [Legacy ESLint configuration files](../configure/configuration-files-deprecated#using-a-shareable-configuration-package) for documentation on the legacy ESLint configuration format |
| 60 | + * [Legacy ESLint configuration files > Using a shareable configuration package](../configure/configuration-files-deprecated#using-a-shareable-configuration-package) for documentation on using shareable configurations |
| 61 | +* [Share Configurations](../../extend/shareable-configs) for documentation on how to define standalone shared configs |
| 62 | +* [Create Plugins > Configs in Plugins](../../extend/plugins#configs-in-plugins) for documentation on how to define shared configs in plugins |
0 commit comments