我想将我的Next.js文件部署到服务器上。当我点击命令时npm run build它显示错误
需要禁用一些 ESLint 规则?在此处了解更多信息: https ://nextjs.org/docs/basic-features/eslint#disabling-rules
我无法找到错误,因为应用程序在本地主机中正常工作,但是当我想要构建时,它显示错误。我的文件中的包package.json是
{
"name": "yourguide-next-frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
},
"dependencies": {
"@emotion/react": "^11.10.0",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.9.3",
"@mui/material": "^5.10.2",
"@tinymce/tinymce-react": "^4.2.0",
"cjs": "^0.0.11",
"cookies": "^0.8.0",
"js-cookie": "^3.0.1",
"next": "12.2.3",
"react": "18.2.0",
"react-bootstrap": "^2.4.0",
"react-dom": "18.2.0",
"tinymce": "^6.1.2"
},
"devDependencies": {
"@next/eslint-plugin-next": "^12.2.5",
"eslint": "8.20.0",
"eslint-config-next": "12.2.3"
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道ESLint rules. 请给我这个问题的解决方案。
kam*_*amp 18
要在 nextjs 中构建期间忽略 eslint,您必须将此行添加到 next.config.js 文件中:
eslint: {
ignoreDuringBuilds: true,
},
Run Code Online (Sandbox Code Playgroud)
最好分享您在构建时遇到的确切错误。
要禁用 eslint 的某些规则,您需要做的就是编辑 .eslintrc.json 文件,使其如下所示,或者您可以添加注释,例如https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main /docs/rules/no-abusive-eslint-disable.md
{ "env": {
"browser": true,
"es2021": true }, "extends": [
"plugin:react/recommended",
"airbnb",
"eslint:recommended",
"plugin:prettier/recommended" ], "parser": "@babel/eslint-parser", "parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module" }, "plugins": [
"react" ], "rules": {
"react/react-in-jsx-scope": "off",
"react/function-component-definition": [
2,
{
"namedComponents": "arrow-function",
"unnamedComponents": "arrow-function"
}
],
"no-use-before-define": [
"error",
{
"functions": false,
"classes": false,
"variables": false
}
],
"react/no-unknown-property": 0,
"no-console": 0,
"no-plusplus": 0, } }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16413 次 |
| 最近记录: |