I am facing build error while deploying the project

11:05:27 PM: build-image version: 4c0c1cadee6a31c9bb8d824514030009c4c05c6a (focal)

11:05:27 PM: build-image tag: v4.15.0

11:05:27 PM: buildbot version: cc0c986a947e274d444f48f63f797a5d01f2a89a

11:05:27 PM: Building without cache

11:05:27 PM: Starting to prepare the repo for build

11:05:27 PM: No cached dependencies found. Cloning fresh repo

11:05:27 PM: git clone https://github.com/csengineer1990/Rat-in-a-Maze---React-Project---jucx8wd3nh2f

11:05:28 PM: Preparing Git Reference refs/heads/master

11:05:28 PM: Parsing package.json dependencies

11:05:29 PM: Section completed: initializing

11:05:30 PM: Starting build script

11:05:30 PM: Installing dependencies

11:05:30 PM: Python version set to 2.7

11:05:30 PM: v16.18.1 is already installed.

11:05:30 PM: Now using node v16.18.1 (npm v8.19.2)

11:05:30 PM: Enabling node corepack

11:05:30 PM: Started restoring cached build plugins

11:05:30 PM: Finished restoring cached build plugins

11:05:30 PM: Attempting ruby version 2.7.2, read from environment

11:05:31 PM: Using ruby version 2.7.2

11:05:31 PM: Using PHP version 8.0

11:05:31 PM: No npm workspaces detected

11:05:31 PM: Started restoring cached node modules

11:05:31 PM: Finished restoring cached node modules

11:05:31 PM: Installing NPM modules using NPM version 8.19.2

11:05:33 PM: npm ERR! code ERESOLVE

11:05:33 PM: npm ERR! ERESOLVE could not resolve

11:05:33 PM: npm ERR!

11:05:33 PM: Creating deploy upload records

11:05:33 PM: npm ERR! While resolving: @mui/styles@5.10.16

11:05:33 PM: npm ERR! Found: react@18.2.0

11:05:33 PM: npm ERR! node_modules/react

11:05:33 PM: npm ERR! react@“^18.2.0” from the root project

11:05:33 PM: npm ERR! peer react@“^17.0.0 || ^18.0.0” from @mui/base@5.0.0-alpha.108

11:05:33 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1 (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)

11:05:33 PM: npm ERR! node_modules/@mui/base

11:05:33 PM: npm ERR! @mui/base@“5.0.0-alpha.108” from @mui/material@5.10.16

11:05:33 PM: npm ERR! node_modules/@mui/material

11:05:33 PM: npm ERR! @mui/material@“^5.10.16” from the root project

11:05:33 PM: npm ERR! 1 more (@mui/icons-material)

11:05:33 PM: npm ERR! 9 more (@mui/icons-material, @mui/material, …)

11:05:33 PM: npm ERR!

11:05:33 PM: npm ERR! Could not resolve dependency:

11:05:33 PM: npm ERR! peer react@“^17.0.0” from @mui/styles@5.10.16

11:05:33 PM: npm ERR! node_modules/@mui/styles

11:05:33 PM: npm ERR! @mui/styles@“^5.10.16” from the root project

11:05:33 PM: npm ERR!

11:05:33 PM: npm ERR! Conflicting peer dependency: react@17.0.2

11:05:33 PM: npm ERR! node_modules/react

11:05:33 PM: npm ERR! peer react@“^17.0.0” from @mui/styles@5.10.16

11:05:33 PM: npm ERR! node_modules/@mui/styles

11:05:33 PM: npm ERR! @mui/styles@“^5.10.16” from the root project

11:05:33 PM: npm ERR!

11:05:33 PM: npm ERR! Fix the upstream dependency conflict, or retry

11:05:33 PM: npm ERR! this command with --force, or --legacy-peer-deps

11:05:33 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

11:05:33 PM: npm ERR!

11:05:33 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.

11:05:33 PM: npm ERR! A complete log of this run can be found in:

11:05:33 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-12-07T17_35_32_192Z-debug-0.log

11:05:33 PM: Error during NPM install

11:05:33 PM: Build was terminated: Build script returned non-zero exit code: 1

11:05:33 PM: Failing build: Failed to build site

11:05:33 PM: Finished processing build request in 6.461283679s

Please see this answer:

Thank you so much sir. firstly i tried with NPM_FLAGS but got error and then i tried with CI= False and NPM_FLAGS = --legacy-peer-deps . its worked sir.