首页 > 解决方案 > 错误:无法加载配置“下一个”以从

问题描述

我有一个使用 jest 和 react-testing-library 进行测试的 Nextjs 应用程序,我将带有 npx .eslintrc --init 命令的 .eslintrc 文件添加到我的项目中。每当我 lint 我的项目时,我都会收到以下错误:

.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": {
}

};

和错误:

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

标签: next.jseslint

解决方案


已解决,安装此包后,代码运行无错误:

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

推荐阅读