# Build script returning non-zero exit code: 2

**URL:** <https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993>\
**Category:** Support\
**Tags:** create-react-app, building, deployment\
**Created:** [April 15, 2022, 7:09am UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993 "2022-04-15T07:09:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seralyn](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/seralyn/32/36228_2.png) [@Seralyn](https://answers.netlify.com/u/Seralyn)\
**Post date:** [April 15, 2022, 7:09am UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993/1 "2022-04-15T07:09:09Z")

</div>

Hi there. New to Netlify as of a few days but I’ve had no issues until now. I’m deploying to my renamed Netlify@  
**seralyn.netlify.app**  
Source Repo: [GitHub - Seralyn/seradevsite: More restrained version of personal website](https://github.com/Seralyn/seradevsite)  
I’ve done this a few times without any problems but I must have done…something…to break the build process and despite looking at the logs, it is not obvious to me.

In my attempts to self-troubleshoot, I have looked through:  
[Frequently Encountered Problems](https://answers.netlify.com/t/support-guide-frequently-encountered-problems-during-builds/213)  
[Using Build Logs to debug Build Process](https://answers.netlify.com/t/support-guide-using-build-logs-to-debug-your-build-process/3067)  
as well as several other people with this error, but their issues don’t seem to be the same as mine.

Here is a copy of my build log:

3:15:48 PM: Build ready to start  
3:15:50 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)  
3:15:50 PM: build-image tag: v4.8.0  
3:15:50 PM: buildbot version: e552b142336b2b1222a93a4fd4cbed0019c77b46  
3:15:50 PM: Fetching cached dependencies  
3:15:50 PM: Starting to download cache of 118.9MB  
3:15:51 PM: Finished downloading cache in 1.356650349s  
3:15:51 PM: Starting to extract cache  
3:15:55 PM: Finished extracting cache in 3.914558478s  
3:15:55 PM: Finished fetching cache in 5.282781121s  
3:15:55 PM: Starting to prepare the repo for build  
3:15:55 PM: Preparing Git Reference refs/heads/master  
3:15:56 PM: Parsing package.json dependencies  
3:15:57 PM: Starting build script  
3:15:57 PM: Installing dependencies  
3:15:57 PM: Python version set to 2.7  
3:15:58 PM: Started restoring cached node version  
3:15:59 PM: Finished restoring cached node version  
3:15:59 PM: v16.14.2 is already installed.  
3:15:59 PM: Now using node v16.14.2 (npm v8.5.0)  
3:15:59 PM: Started restoring cached build plugins  
3:15:59 PM: Finished restoring cached build plugins  
3:16:00 PM: Attempting ruby version 2.7.2, read from environment  
3:16:01 PM: Using ruby version 2.7.2  
3:16:01 PM: Using PHP version 8.0  
3:16:01 PM: No npm workspaces detected  
3:16:01 PM: Started restoring cached node modules  
3:16:01 PM: Finished restoring cached node modules  
3:16:02 PM: Installing NPM modules using NPM version 8.5.0  
3:16:08 PM: added 4 packages, changed 15 packages, and audited 1393 packages in 6s  
3:16:08 PM: 172 packages are looking for funding  
3:16:08 PM: run `npm fund` for details  
3:16:08 PM: 12 vulnerabilities (5 moderate, 7 high)  
3:16:08 PM: To address all issues (including breaking changes), run:  
3:16:08 PM: npm audit fix --force  
3:16:08 PM: Run `npm audit` for details.  
3:16:08 PM: NPM modules installed  
3:16:08 PM: Started restoring cached go cache  
3:16:08 PM: Finished restoring cached go cache  
3:16:08 PM: go version go1.16.5 linux/amd64  
3:16:08 PM: go version go1.16.5 linux/amd64  
3:16:08 PM: Installing missing commands  
3:16:08 PM: Verify run directory  
3:16:10 PM: ​  
3:16:10 PM: ────────────────────────────────────────────────────────────────  
3:16:10 PM: Netlify Build  
3:16:10 PM: ────────────────────────────────────────────────────────────────  
3:16:10 PM: ​  
3:16:10 PM: ❯ Version  
3:16:10 PM: @netlify/build 26.5.2  
3:16:10 PM: ​  
3:16:10 PM: ❯ Flags  
3:16:10 PM: baseRelDir: true  
3:16:10 PM: buildId: 62590d9410be237d259bda84  
3:16:10 PM: deployId: 62590d9410be237d259bda86  
3:16:10 PM: ​  
3:16:10 PM: ❯ Current directory  
3:16:10 PM: /opt/build/repo  
3:16:10 PM: ​  
3:16:10 PM: ❯ Config file  
3:16:10 PM: No config file was defined: using default values.  
3:16:10 PM: ​  
3:16:10 PM: ❯ Context  
3:16:10 PM: production  
3:16:10 PM: ​  
3:16:10 PM: ────────────────────────────────────────────────────────────────  
3:16:10 PM: 1. Build command from Netlify app  
3:16:10 PM: ────────────────────────────────────────────────────────────────  
3:16:10 PM: ​  
3:16:10 PM: $ npm run build  
3:16:10 PM: \> seradevsite@0.1.0 build  
3:16:10 PM: \> react-scripts build  
3:16:11 PM: Creating an optimized production build…  
3:16:21 PM:  
3:16:21 PM: Treating warnings as errors because process.env.CI = true.  
3:16:21 PM: Most CI servers set it automatically.  
3:16:21 PM:  
3:16:21 PM: Failed to compile.  
3:16:21 PM:  
3:16:21 PM: src/components/About.js  
3:16:21 PM: Line 19:13: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text  
3:16:21 PM: src/components/LandingPage.js  
3:16:21 PM: Line 10:9: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text  
3:16:21 PM: ​  
3:16:21 PM: ────────────────────────────────────────────────────────────────  
3:16:21 PM: “build.command” failed  
3:16:21 PM: ────────────────────────────────────────────────────────────────  
3:16:21 PM: ​  
3:16:21 PM: Error message  
3:16:21 PM: Command failed with exit code 1: npm run build ([Search results for '"non-zero exit code: 1"' - Netlify Support Forums](https://ntl.fyi/exit-code-1))  
3:16:21 PM: Creating deploy upload records  
3:16:21 PM: ​  
3:16:21 PM: Error location  
3:16:21 PM: In Build command from Netlify app:  
3:16:21 PM: npm run build  
3:16:21 PM: ​  
3:16:21 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 ([Search results for '"non-zero exit code: 2"' - Netlify Support Forums](https://ntl.fyi/exit-code-2))  
3:16:21 PM: Resolved config  
3:16:21 PM: build:  
3:16:21 PM: command: npm run build  
3:16:21 PM: commandOrigin: ui  
3:16:21 PM: environment:  
3:16:21 PM: - ONEGRAPH\_AUTHLIFY\_TOKEN  
3:16:21 PM: publish: /opt/build/repo/build  
3:16:21 PM: publishOrigin: ui  
3:16:21 PM: Caching artifacts  
3:16:21 PM: Started saving node modules  
3:16:21 PM: Finished saving node modules  
3:16:21 PM: Started saving build plugins  
3:16:21 PM: Finished saving build plugins  
3:16:21 PM: Started saving pip cache  
3:16:21 PM: Finished saving pip cache  
3:16:21 PM: Started saving emacs cask dependencies  
3:16:21 PM: Finished saving emacs cask dependencies  
3:16:21 PM: Started saving maven dependencies  
3:16:21 PM: Finished saving maven dependencies  
3:16:21 PM: Started saving boot dependencies  
3:16:21 PM: Finished saving boot dependencies  
3:16:21 PM: Started saving rust rustup cache  
3:16:21 PM: Finished saving rust rustup cache  
3:16:21 PM: Started saving go dependencies  
3:16:21 PM: Finished saving go dependencies  
3:16:21 PM: Build failed due to a user error: Build script returned non-zero exit code: 2  
3:16:21 PM: Failing build: Failed to build site  
3:16:22 PM: Finished processing build request in 31.782508308s

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [April 17, 2022, 5:14pm UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993/2 "2022-04-17T17:14:38Z")

</div>

Hi @Seralyn,

Try changing build command in your site settings to:

```auto
CI= npm run build

```

---

<div class="post-metadata">

**Author:** ![Seralyn](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/seralyn/32/36228_2.png) [@Seralyn](https://answers.netlify.com/u/Seralyn)\
**Post date:** [April 18, 2022, 5:53am UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993/3 "2022-04-18T05:53:48Z")

</div>

Thanks @hrishikesh ! Funnily enough, I figured that out after you posted this, but before I read it 😛 Thanks for your help anyway!

---

<div class="post-metadata">

**Author:** ![Seralyn](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/seralyn/32/36228_2.png) [@Seralyn](https://answers.netlify.com/u/Seralyn)\
**Post date:** [April 22, 2022, 2:45am UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993/4 "2022-04-22T02:45:46Z")

</div>

that was supposed to be “npm” right? “rpm” is a typo?

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [April 22, 2022, 12:12pm UTC](https://answers.netlify.com/t/build-script-returning-non-zero-exit-code-2/54993/5 "2022-04-22T12:12:01Z")

</div>

Yes, my bad. It’s `npm`. Updated it now.
