简体   繁体   English

ESLint:8.0.0 无法加载插件'@typescript-eslint'

[英]ESLint: 8.0.0 Failed to load plugin '@typescript-eslint'

Could you help me, I've got this error when I try building a project?你能帮我吗,我在尝试构建项目时遇到了这个错误?

Oops: Something went wrong!哎呀!出事了! :( :(

ESLint: 8.0.0 ESLint:8.0.0

TypeError: Failed to load plugin '@typescript-eslint' declared in 'src.eslintrc': Class extends value undefined is not a constructor or null Referenced from: src.eslintrc TypeError:无法加载在“src.eslintrc”中声明的插件“@typescript-eslint”:Class 扩展值未定义不是构造函数或 null 引用自:src.eslintrc

package.json package.json

    "devDependencies": {
        "@typescript-eslint/eslint-plugin": "^4.33.0",
        "@typescript-eslint/parser": "^4.33.0",
        "browserslist": "^4.17.3",
        "eslint": "^8.0.0",
        "eslint-config-prettier": "^8.3.0",
        "eslint-plugin-import": "^2.24.2",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-react": "^7.26.1",
        "prettier": "^2.3.2",
    }

.eslintrc .eslintrc

    "parser": "@typescript-eslint/parser",
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:prettier/recommended",
        "prettier"
    ],
    "plugins": ["@typescript-eslint"],

This issue was quite persistent for me.这个问题对我来说非常持久。 The simple solution that worked was to reload VS Code .有效的简单解决方案是reload VS Code

在此处输入图像描述

There is probably an ESM compatibility problem with one of the packages, so either you must make sure all your deps are ESM compatible or lock eslint to 7.32.0 & upgrade the plugins as (I'd also recommend to add typescript to your dev deps):其中一个软件包可能存在 ESM 兼容性问题,因此您必须确保所有 deps都与 ESM 兼容,或者将 eslint 锁定到 7.32.0 并将插件升级为(我还建议将 typescript 添加到您的 dev deps ):

  "devDependencies": {
    ...
    "@typescript-eslint/eslint-plugin": "^5.6.0",
    "@typescript-eslint/parser": "^5.6.0",
    "eslint": "^7.32.0",
    "typescript": "^4.4.3"
  }

I did this and it work just fine for me我做了这个,它对我来说很好用

"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.1.0",

Update those three packages更新这三个包

Then run in the root of your project this command to update the packages然后在项目的根目录中运行此命令以更新包

npm i

And it will work fine它会正常工作

I saw this error trying to use version 4.xx of the @typescript-eslint packages:我在尝试使用 @typescript-eslint 包的 4.xx 版时看到了这个错误:

  "devDependencies": {
    ...
    "@typescript-eslint/eslint-plugin": "^4.29.1",
    "@typescript-eslint/parser": "^4.29.1",
    ...
}

Fix was to update these to the version "^5.3.1"修复是将这些更新到版本"^5.3.1"

I had this issue when my node version wasn't compatible with the react version I was using.当我的节点版本与我使用的反应版本不兼容时,我遇到了这个问题。 Check the logs and update to a compatible version of nodejs检查日志并更新到兼容版本的 nodejs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ESLint 无法识别“@typescript-eslint/eslint-plugin” - ESLint is not recognizing "@typescript-eslint/eslint-plugin" eslint 缩进和@typescript-eslint/indent 冲突 - eslint indent and @typescript-eslint/indent conflict @typescript-eslint/eslint-plugin 错误:定义了“路由”但从未使用过(no-unused-vars) - @typescript-eslint/eslint-plugin error: 'Route' is defined but never used (no-unused-vars) 无法加载在 'package.json » eslint-config-react-app#overrides[0]' 中声明的解析器 '@typescript-eslint/parser':找不到模块 'typescript' - Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' angular-eslint 和 typescript-eslint 之间的区别 - Difference between angular-eslint and typescript-eslint @typescript-eslint/no-unsafe-* 规则的新 eslint 错误 - New eslint errors with the @typescript-eslint/no-unsafe-* rules ESLint 找不到插件“eslint-plugin-@typescript-eslint” - ESLint couldn't find the plugin "eslint-plugin-@typescript-eslint" TypeScript 和 typescript-eslint 有重叠的用途吗? - Do TypeScript and typescript-eslint have overlapping purposes? @typescript-eslint/no-unused-vars 类型声明中的误报 - @typescript-eslint/no-unused-vars false positive in type declarations @typescript-eslint/no-unsafe-assignment:任何值的不安全赋值 - @typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM