我刚刚通过
npx nuxi upgrade
在我的项目中升级了 nuxt,现在当我运行 eslint .
时,我有这个输出
=============
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=4.3.5 <5.4.0
YOUR TYPESCRIPT VERSION: 5.4.3
Please only submit bug reports when using the officially supported version.
=============
我发现旧版本的 nuxt 使用
"@nuxt/eslint-config": "^0.2.0"
来配置 ESLint。您可以在here查看此配置。
正如您在代码中看到的,它取决于 @typescript-eslint/eslint-plugin, @typescript-eslint/parser
,然后我查看了 package-lock.json 和这个 "@nuxt/eslint-config"
包。
这里是包配置:
package-lock.json
"node_modules/@nuxt/eslint-config": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@nuxt/eslint-config/-/eslint-config-0.2.0.tgz",
"integrity": "sha512-NeJX8TLcnNAjQFiDs3XhP+9CHKK8jaKsP7eUyCSrQdgY7nqWe7VJx64lwzx5FTT4cW3RHMEyH+Y0qzLGYYoa/A==",
"dev": true,
"dependencies": {
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint-plugin-vue": "^9.17.0",
"typescript": "^5.2.2"
},
"peerDependencies": {
"eslint": "^8.48.0"
}
},
@typescript-eslint/eslint-plugin
和@typescript-eslint/parser
有6.5.0版本。但是最新的是7.5.0。因此,nuxt 通过 npx nuxi upgrade
更新了 typescript,但没有更新 @nuxt/eslint-config
。实际上没有更新版本了:)
修复它的最佳方法是使用
npm install -D @typescript-eslint/eslint-plugin @typescript-eslint/parser --legacy-peer-deps
--legacy-peer-deps
在依赖树上安装你的包,你不会看到任何冲突。