MUHAMMAD HARIS
MUHAMMAD HARIS

Reputation: 121

"Need to disable some ESLint rules" error while make the build of next js app

I want to deploy my Next.js file on the server. When I hit the command npm run build it shows the error

Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules

I am unable to find the mistake because the app is working properly in localhost but when I want to make the build it shows an error. the packages in my package.json file is

{
  "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"
  }
}

I don't know the ESLint rules. kindly give me the solution of this problem.

Upvotes: 11

Views: 34054

Answers (6)

uttam pun
uttam pun

Reputation: 1

for nextjs typescript

    import type { NextConfig } from "next";
    
    const nextConfig: NextConfig = {
      /* ignore build errors */
      ignoreBuildErrors: true,

eslint:{
    ignoreDuringBuilds: true, during builds
  }
     
};

export default nextConfig;

Upvotes: 0

Vishesh Mangla
Vishesh Mangla

Reputation: 753

Please look at this link

https://nextjs.org/docs/app/api-reference/next-config-js/typescript

In next.config.js

module.exports = {
  typescript: {
    // !! WARN !!
    // Dangerously allow production builds to successfully complete even if
    // your project has type errors.
    // !! WARN !!
    ignoreBuildErrors: true,
  },
}

Upvotes: 2

kamp
kamp

Reputation: 585

To ignore eslint during build in nextjs, you have to add this line to the next.config.js file:

eslint: {
    ignoreDuringBuilds: true,
},

Upvotes: 29

Peter Ngugi
Peter Ngugi

Reputation: 111

You can ignore eslint by editing your next.config.js file.

Example:

/** @type {import('next').NextConfig} */

const nextConfig = {
    eslint: {
        ignoreDuringBuilds: true,
    },
/* ...Your other config rules */
}

module.exports = nextConfig

This will ignores eslint, if you want to keep the eslint rules try running the build command locally and fix the errors that pop up.

Upvotes: 5

la39zz
la39zz

Reputation: 310

I got the same error too I fixed it by just removing the eslint dependency from my package.json

Upvotes: -2

SRV
SRV

Reputation: 45

It would be good to share the exact error you are getting when making the build.

To disable some rules for eslint all you need to do is edit your .eslintrc.json file to make it look like below or you can add comments like 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,   } }

Upvotes: 0

Related Questions