I get this build error: Failed during stage 'building site': Build script returned non-zero exit code: 2

**I get This Build Error, but when building locally no error acures, netlify site name: monstercatclone.netlify.app **

2:51:24 PM: Netlify Build
2:51:24 PM: ────────────────────────────────────────────────────────────────
2:51:24 PM: ​
2:51:24 PM: ❯ Version
2:51:24 PM: @netlify/build 29.18.1
2:51:24 PM: ​
2:51:24 PM: ❯ Flags
2:51:24 PM: baseRelDir: true
2:51:24 PM: buildId: 64d399c7550418000873925c
2:51:24 PM: deployId: 64d399c7550418000873925e
2:51:24 PM: ​
2:51:24 PM: ❯ Current directory
2:51:24 PM: /opt/build/repo
2:51:24 PM: ​
2:51:24 PM: ❯ Config file
2:51:24 PM: No config file was defined: using default values.
2:51:24 PM: ​
2:51:24 PM: ❯ Context
2:51:24 PM: production
2:51:24 PM: ​
2:51:24 PM: Build command from Netlify app
2:51:24 PM: ────────────────────────────────────────────────────────────────
2:51:24 PM: ​
2:51:24 PM: $ npm run build
2:51:24 PM: > monstercat@0.0.0 build
2:51:24 PM: > tsc && vite build
2:51:28 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)
2:51:26 PM: vite v4.4.8 building for production…
2:51:26 PM: transforming…
2:51:26 PM: ✓ 64 modules transformed.
2:51:26 PM: ✓ built in 305ms
2:51:26 PM: Could not resolve ./TrackList.css from src/components/TrackList.tsx
2:51:26 PM: file: /opt/build/repo/src/components/TrackList.tsx
2:51:26 PM: error during build:
2:51:26 PM: RollupError: Could not resolve ./TrackList.css from src/components/TrackList.tsx
2:51:26 PM: at error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
2:51:26 PM: at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:24674:24)
2:51:26 PM: at file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:24636:26
2:51:26 PM: ​
2:51:26 PM: build.command failed
2:51:26 PM: ────────────────────────────────────────────────────────────────
2:51:26 PM: ​
2:51:26 PM: Error message
2:51:26 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
2:51:26 PM: ​
2:51:26 PM: Error location
2:51:26 PM: In Build command from Netlify app:
2:51:26 PM: npm run build
2:51:26 PM: ​

2:51:26 PM: Resolved config
2:51:26 PM: build:
2:51:26 PM: command: npm run build
2:51:26 PM: commandOrigin: ui
2:51:26 PM: publish: /opt/build/repo/dist
2:51:26 PM: publishOrigin: ui
2:51:28 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:51:28 PM: Failing build: Failed to build site
2:51:28 PM: Finished processing build request in 23.294s

Hi there, glad you found us :wave: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console