javascript - ESLint:8.0.0 无法加载插件'@typescript-eslint'
问题描述
你能帮我吗,我在尝试构建项目时遇到了这个错误?
哎呀!出问题了!:(
ESLint:8.0.0
TypeError:无法加载在“src.eslintrc”中声明的插件“@typescript-eslint”:类扩展值未定义不是构造函数或 null 引用自:src.eslintrc
包.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
"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"],
解决方案
我这样做了,它对我来说很好用
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.1.0",
更新这三个包
然后在项目的根目录中运行此命令以更新包
npm i
它会正常工作