我刚刚用
创建了一个新项目npx create-next-app@latest --ts
当我运行
npm run lint
我得到了错误:
下一个线头info -使用webpack 5。原因:默认开启https://nextjs.org/docs/messages/webpack5必须安装ESLint: yarn add——dev ESLint
但是eslint
已经安装了!
可能是什么?
复制步骤:
npx create-next-app@latest --ts
cd app
npm install
npm run lint
Mypackage.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:css": "stylelint '**/*.{css,tsx}'",
"format": "prettier '**/*' --write --ignore-unknown",
"prepare": "husky install"
},
"dependencies": {
"next": "11.1.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@stylelint/postcss-css-in-js": "^0.37.2",
"@types/react": "17.0.31",
"eslint": "^8.0.1",
"eslint-config-next": "11.1.2",
"husky": "^7.0.4",
"postcss-syntax": "^0.36.2",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.1",
"stylelint": "^14.0.0",
"stylelint-config-standard": "^23.0.0",
"stylelint-config-styled-components": "^0.1.1",
"typescript": "4.4.4"
}
}
这是一个已知的问题,现在已经修复。
你可以升级nextjs v12。源
这个问题与eslint 8.0.1有关。降级到7.32.0.
您可以在这个开放的错误中找到更多信息:https://github.com/vercel/next.js/issues/29961#issuecomment-945823476
如果您仍然得到这个问题,请尝试查找.eslintrc
文件,看看它是否已经存在。如果存在,请删除并重新运行npm run lint
。这样做解决了我的问题。