尝试将eslint安装到 中yarn create next-app
,但运行 linter 时出现下一个错误:
错误:无法加载“.eslintrc.js”中声明的解析器“@babel/eslint-parser”:找不到模块“@babel/core/package.json”
细节:
info - Loaded env from /project/.env
Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module '@babel/core/package.json'
Require stack:
- /project/node_modules/@babel/eslint-parser/lib/parse.cjs
- /project/node_modules/@babel/eslint-parser/lib/index.cjs
- /project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)
这是我的.eslintrc.js
配置文件:
browser: true,
es2020: true,
es6: true,
node: true
},
extends: ['airbnb', 'prettier', 'next/core-web-vitals'],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2021,
requireConfigFile: false
},
plugins: …
Run Code Online (Sandbox Code Playgroud)