M.H
M.H

Reputation: 541

Error: Failed to load config "next" to extend from

I have a Nextjs app using jest and react-testing-library for the test, I add the .eslintrc file with npx .eslintrc --init command to my project. whenever I lint my project, I get the following error:

.eslintrc.js:

module.exports = {
"extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "next",
    "next/core-web-vitals"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
    "project":"./tsconfig.json",
    "ecmaFeatures": {
        "jsx": true
    },
    "ecmaVersion": 12,
    "sourceType": "module"
},
"rules": {
}

};

and error:

info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Error: Failed to load config "next" to extend from.
Referenced from: D:\web\reactjs\react-testing\react-testing-app\.eslintrc.js

Upvotes: 20

Views: 14573

Answers (3)

Olivier RUBUZ
Olivier RUBUZ

Reputation: 1

Juste remove "next/typescript" in your .eslintrc.json file.

Default config that's not working :

{ "extends": ["next/core-web-vitals", "next/typescript"] }

Correct config :

{ "extends": "next/core-web-vitals" }

Upvotes: -1

Alex 75
Alex 75

Reputation: 3236

For a misterious reason running npm audit fix --force changed my package.json from:

"eslint-config-next": "12.0.1"

to:

"eslint-config-next": "^0.2.4"

I had to change it manually and the error went away.

Upvotes: 8

M.H
M.H

Reputation: 541

Resolved, after installing this package, the code will run without error:

npm i --save-dev eslint-config-next

Upvotes: 32

Related Questions