Build script returned non-zero exit code: 2 appears when I try to deploy site

I don’t know what happens but every time I try to deploy my site on Netlify through github, it fails.
This is the repository I am deploying from: github.com/egg899/FCC-random-quote-machine

This would be the URL:
stellular-semolina-5c78d1.netlify.app

This is what I get:
12:14:21 AM: Netlify Build
12:14:21 AM: ────────────────────────────────────────────────────────────────
12:14:21 AM: ​
12:14:21 AM: ❯ Version
12:14:21 AM: @netlify/build 29.20.12
12:14:21 AM: ​
12:14:21 AM: ❯ Flags
12:14:21 AM: baseRelDir: true
12:14:21 AM: buildId: 64fd3480db4b094d1aa184b2
12:14:21 AM: deployId: 64fd3480db4b094d1aa184b4
12:14:21 AM: ​
12:14:21 AM: ❯ Current directory
12:14:21 AM: /opt/build/repo
12:14:21 AM: ​
12:14:21 AM: ❯ Config file
12:14:21 AM: No config file was defined: using default values.
12:14:21 AM: ​
12:14:21 AM: ❯ Context
12:14:21 AM: production
12:14:21 AM: ​
12:14:21 AM: Build command from Netlify app
12:14:21 AM: ────────────────────────────────────────────────────────────────
12:14:21 AM: ​
12:14:21 AM: $ npm run build
12:14:21 AM: > random-quote-machine@0.0.0 build
12:14:21 AM: > tsc && vite build
12:14:22 AM: src/App.tsx(3,1): error TS6133: ‘Button’ is declared but its value is never read.
12:14:22 AM: src/App.tsx(3,20): error TS7016: Could not find a declaration file for module ‘./assets/Button.jsx’. ‘/opt/build/repo/src/assets/Button.jsx’ implicitly has an ‘any’ type.
12:14:22 AM: src/App.tsx(40,11): error TS6133: ‘result’ is declared but its value is never read.
12:14:22 AM: src/App.tsx(81,17): error TS2339: Property ‘content’ does not exist on type ‘never’.
12:14:22 AM: src/App.tsx(85,31): error TS2339: Property ‘author’ does not exist on type ‘never’.
12:14:22 AM: src/App.tsx(91,100): error TS2339: Property ‘content’ does not exist on type ‘never’.
12:14:22 AM: src/App.tsx(91,116): error TS2339: Property ‘author’ does not exist on type ‘never’.
12:14:22 AM: ​
12:14:22 AM: build.command failed
12:14:22 AM: ────────────────────────────────────────────────────────────────
12:14:22 AM: ​
12:14:22 AM: Error message
12:14:22 AM: Command failed with exit code 2: npm run build (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
12:14:22 AM: ​
12:14:22 AM: Error location
12:14:22 AM: In Build command from Netlify app:
12:14:22 AM: npm run build
12:14:22 AM: ​
12:14:22 AM: Resolved config
12:14:22 AM: build:
12:14:22 AM: command: npm run build
12:14:22 AM: commandOrigin: ui
12:14:22 AM: environment:
12:14:22 AM: - CI
12:14:22 AM: - DEPRECATED
12:14:22 AM: publish: /opt/build/repo/dist
12:14:22 AM: publishOrigin: ui
12:14:23 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:14:23 AM: Failing build: Failed to build site
12:14:24 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
12:14:24 AM: Finished processing build request in 13.679s
12:14:25 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)

See:

Your build is throwing warnings.
There is an environment variable of CI which defaults to true.
When it is true warnings are treated as errors.
Errors cause your build to fail.

Adjust your Build command to CI= npm run build so that it is set to false.

Sorry I am a newbie at this. How can I do that?

Hi, I was able to do it in the deployment setting when I re-linked my project but it is the same problem.

@egg899 Then you’ve likely still got it all configured incorrectly.

The documentation for Build configuration is here:

There should be no need to re-link your project, just make sure everything is configured correctly for whatever your specific project requires.