Command failed with exit code 1 , how to resolve

site:resilient-daffodil-9395b0
I am not able to deploy my react project . It was saying ‘Command failed with exit code 1’
I am pasting my code here.

8:38:10 PM: Build ready to start
8:38:30 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
8:38:30 PM: build-image tag: v4.10.1
8:38:30 PM: buildbot version: 245d5f7dbba71532ad47f93e1b672d3e4e202cee
8:38:31 PM: Fetching cached dependencies
8:38:31 PM: Failed to fetch cache, continuing with build
8:38:31 PM: Starting to prepare the repo for build
8:38:31 PM: No cached dependencies found. Cloning fresh repo
8:38:31 PM: git clone https://github.com/bottle88/ecommerce
8:38:31 PM: Preparing Git Reference refs/heads/main
8:38:32 PM: Parsing package.json dependencies
8:38:33 PM: Starting build script
8:38:33 PM: Installing dependencies
8:38:33 PM: Python version set to 2.7
8:38:34 PM: v16.16.0 is already installed.
8:38:34 PM: Now using node v16.16.0 (npm v8.11.0)
8:38:34 PM: Started restoring cached build plugins
8:38:34 PM: Finished restoring cached build plugins
8:38:34 PM: Attempting ruby version 2.7.2, read from environment
8:38:35 PM: Using ruby version 2.7.2
8:38:36 PM: Using PHP version 8.0
8:38:36 PM: Started restoring cached yarn cache
8:38:36 PM: Finished restoring cached yarn cache
8:38:36 PM: No yarn workspaces detected
8:38:36 PM: Started restoring cached node modules
8:38:36 PM: Finished restoring cached node modules
8:38:36 PM: Installing NPM modules using Yarn version 1.22.10
8:38:37 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:38:37 PM: npm WARN config location in the cache, and they are managed by
8:38:37 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:38:37 PM: yarn install v1.22.10
8:38:37 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
8:38:37 PM: [1/4] Resolving packages...
8:38:37 PM: [2/4] Fetching packages...
8:39:18 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
8:39:18 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
8:39:18 PM: [3/4] Linking dependencies...
8:39:18 PM: warning "@emotion/react > @emotion/babel-plugin@11.9.2" has unmet peer dependency "@babel/core@^7.0.0".
8:39:18 PM: warning "@emotion/react > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
8:39:18 PM: warning " > @mui/icons-material@5.8.4" has unmet peer dependency "@mui/material@^5.0.0".
8:39:18 PM: warning " > @testing-library/user-event@12.8.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
8:39:18 PM: warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
8:39:18 PM: warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
8:39:18 PM: warning "react-scripts > react-dev-utils > fork-ts-checker-webpack-plugin@6.5.2" has unmet peer dependency "typescript@>= 2.7".
8:39:18 PM: warning "react-scripts > eslint-config-react-app > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
8:39:18 PM: warning " > styled-components@5.3.5" has unmet peer dependency "react-is@>= 16.8.0".
8:39:40 PM: [4/4] Building fresh packages...
8:39:41 PM: success Saved lockfile.
8:39:41 PM: Done in 64.74s.
8:39:41 PM: NPM modules installed using Yarn
8:39:42 PM: Started restoring cached go cache
8:39:42 PM: Finished restoring cached go cache
8:39:42 PM: Installing Go version 1.17 (requested 1.17)
8:39:47 PM: unset GOOS;
8:39:47 PM: unset GOARCH;
8:39:47 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
8:39:47 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
8:39:47 PM: go version >&2;
8:39:47 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
8:39:47 PM: go version go1.17 linux/amd64
8:39:47 PM: Installing missing commands
8:39:47 PM: Verify run directory
8:39:48 PM: ​
8:39:48 PM: ────────────────────────────────────────────────────────────────
8:39:48 PM:   Netlify Build                                                 
8:39:48 PM: ────────────────────────────────────────────────────────────────
8:39:48 PM: ​
8:39:48 PM: ❯ Version
8:39:48 PM:   @netlify/build 27.6.0
8:39:48 PM: ​
8:39:48 PM: ❯ Flags
8:39:48 PM:   baseRelDir: true
8:39:48 PM:   buildId: 62e2a65a87a9612af6510c71
8:39:48 PM:   deployId: 62e2a65a87a9612af6510c73
8:39:48 PM: ​
8:39:48 PM: ❯ Current directory
8:39:48 PM:   /opt/build/repo
8:39:48 PM: ​
8:39:48 PM: ❯ Config file
8:39:48 PM:   No config file was defined: using default values.
8:39:48 PM: ​
8:39:48 PM: ❯ Context
8:39:48 PM:   production
8:39:48 PM: ​
8:39:48 PM: ────────────────────────────────────────────────────────────────
8:39:48 PM:   1. Build command from Netlify app                             
8:39:48 PM: ────────────────────────────────────────────────────────────────
8:39:48 PM: ​
8:39:48 PM: $ yarn build
8:39:48 PM: yarn run v1.22.10
8:39:48 PM: $ react-scripts build
8:39:50 PM: Creating an optimized production build...
8:39:54 PM: Failed to compile.
8:39:54 PM: 
8:39:54 PM: Module not found: Error: Can't resolve '@mui/system' in '/opt/build/repo/src/components'
8:39:54 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
8:39:54 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
8:39:54 PM: ​
8:39:54 PM: ────────────────────────────────────────────────────────────────
8:39:54 PM:   "build.command" failed                                        
8:39:54 PM: ────────────────────────────────────────────────────────────────
8:39:54 PM: ​
8:39:54 PM:   Error message
8:39:54 PM:   Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
8:39:54 PM: ​
8:39:54 PM:   Error location
8:39:54 PM:   In Build command from Netlify app:
8:39:54 PM:   yarn build
8:39:54 PM: ​
8:39:54 PM:   Resolved config
8:39:54 PM:   build:
8:39:54 PM:     command: yarn build
8:39:54 PM:     commandOrigin: ui
8:39:54 PM:     publish: /opt/build/repo/build
8:39:54 PM:     publishOrigin: ui
8:39:55 PM: Caching artifacts
8:39:55 PM: Started saving node modules
8:39:55 PM: Finished saving node modules
8:39:55 PM: Started saving build plugins
8:39:55 PM: Finished saving build plugins
8:39:55 PM: Started saving yarn cache
8:40:03 PM: Finished saving yarn cache
8:40:03 PM: Started saving pip cache
8:40:03 PM: Finished saving pip cache
8:40:03 PM: Started saving emacs cask dependencies
8:40:03 PM: Finished saving emacs cask dependencies
8:40:03 PM: Started saving maven dependencies
8:40:03 PM: Finished saving maven dependencies
8:40:03 PM: Started saving boot dependencies
8:40:03 PM: Finished saving boot dependencies
8:40:03 PM: Started saving rust rustup cache
8:40:03 PM: Finished saving rust rustup cache
8:40:03 PM: Started saving go dependencies
8:40:03 PM: Finished saving go dependencies
8:40:04 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:40:04 PM: Creating deploy upload records
8:40:04 PM: Failing build: Failed to build site
8:40:04 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:40:05 PM: Finished processing build request in 1m34.23450337s

Hello @bottle88

Welcome to our community! What is the behaviour of your build, locally?

Can you please try to match your Netlify node/npm versions to match you local environment, if it builds properly on your machine?

You can set the same versions using build environment variables:

Do this and try to run another build, please!

Hope this helps :crossed_fingers:

Thanks for the support , I will try this one and get back if it’s not resolved

Hey, I tried deploying manually this time , and it worked like charm . Maybe I may have missed filling some build Information while deploying through github .