[英]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"],
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"
}
https://github.com/typescript-eslint/typescript-eslint/issues/3982 https://github.com/typescript-eslint/typescript-eslint/issues/3982
It seems to be a compatibility problem好像是兼容性问题
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.