Cant deploy: Failed during stage 'building site': Build script returned non-zero exit code: 2

Hello everyone!
Im getting an error when deploying my site to netlify. I added React Router to my React App and i think after adding it, it broke the deployment.

Its not able to resolve some paths but i dont know. It works on my local machine when i run npm run dev.

Ive got a main.jsx file in the src folder and a pages folder aswell as a components folder.
The pages folder includes:

  • home.jsx
  • faq.jsx
  • error.jsx

The components folder includes:

  • footer.jsx
  • form.jsx
  • navbar.jsx
  • pageload.jsx

Error Log:

11:30:36 AM: build-image version: fcb0c1b3ada6d25c1cb58e8bc514f5f23cc14f15 (focal)
11:30:36 AM: buildbot version: ee2ef905a4bdb64f7733dd60a718aa00319e6f82
11:30:37 AM: Fetching cached dependencies
11:30:37 AM: Failed to fetch cache, continuing with build
11:30:37 AM: Starting to prepare the repo for build
11:30:37 AM: No cached dependencies found. Cloning fresh repo
11:30:37 AM: git clone --filter=blob:none GitHub - meisteraxel/rohmilch-kaufen.de
11:30:37 AM: Preparing Git Reference refs/heads/main
11:30:39 AM: Starting to install dependencies
11:30:41 AM: Python version set to 3.8
11:30:41 AM: Attempting Ruby version 2.7.2, read from environment
11:30:42 AM: Using Ruby version 2.7.2
11:30:43 AM: Started restoring cached go cache
11:30:43 AM: Finished restoring cached go cache
11:30:44 AM: go version go1.19.13 linux/amd64
11:30:45 AM: Using PHP version 8.0
11:30:46 AM: Downloading and installing node v18.20.2…
11:30:46 AM: Downloading https://nodejs.org/dist/v18.20.2/node-v18.20.2-linux-x64.tar.xz…
11:30:47 AM: Computing checksum with sha256sum
11:30:47 AM: Checksums matched!
11:30:49 AM: Now using node v18.20.2 (npm v10.5.0)
11:30:49 AM: Enabling Node.js Corepack
11:30:49 AM: Started restoring cached build plugins
11:30:49 AM: Finished restoring cached build plugins
11:30:49 AM: Started restoring cached corepack dependencies
11:30:49 AM: Finished restoring cached corepack dependencies
11:30:49 AM: No npm workspaces detected
11:30:49 AM: Started restoring cached node modules
11:30:49 AM: Finished restoring cached node modules
11:30:49 AM: Installing npm packages using npm version 10.5.0
11:30:53 AM: added 365 packages, and audited 366 packages in 4s
11:30:53 AM: 126 packages are looking for funding
11:30:53 AM: run npm fund for details
11:30:53 AM: found 0 vulnerabilities
11:30:53 AM: npm packages installed
11:30:54 AM: Successfully installed dependencies
11:30:54 AM: Starting build script
11:30:57 AM: Detected 1 framework(s)
11:30:57 AM: β€œvite” at version β€œ5.2.8”
11:30:57 AM: Section completed: initializing
11:30:58 AM: ​
11:30:58 AM: Netlify Build
11:30:58 AM: ────────────────────────────────────────────────────────────────
11:30:58 AM: ​
11:30:58 AM: ❯ Version
11:30:58 AM: @netlify/build 29.39.1
11:30:58 AM: ​
11:30:58 AM: ❯ Flags
11:30:58 AM: baseRelDir: true
11:30:58 AM: buildId: 6617adb23fea2600071d9671
11:30:58 AM: deployId: 6617adb23fea2600071d9673
11:30:58 AM: ​
11:30:58 AM: ❯ Current directory
11:30:58 AM: /opt/build/repo
11:30:58 AM: ​
11:30:58 AM: ❯ Config file
11:30:58 AM: No config file was defined: using default values.
11:30:58 AM: ​
11:30:58 AM: ❯ Context
11:30:58 AM: production
11:30:58 AM: ​
11:30:58 AM: Build command from Netlify app
11:30:58 AM: ────────────────────────────────────────────────────────────────
11:30:58 AM: ​
11:30:58 AM: $ npm run build
11:30:58 AM: > rohmilch-kaufen@0.0.0 build
11:30:58 AM: > vite build
11:30:58 AM: vite v5.2.8 building for production…
11:30:59 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)
11:30:59 AM: transforming…
11:30:59 AM: βœ“ 20 modules transformed.
11:30:59 AM: x Build failed in 497ms
11:30:59 AM: error during build:
11:30:59 AM: RollupError: Could not resolve β€œβ€¦/components/footer.jsx” from β€œsrc/pages/faq.jsx”
11:30:59 AM: file: /opt/build/repo/src/pages/faq.jsx
11:30:59 AM: at getRollupError (file:///opt/build/repo/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
11:30:59 AM: at error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
11:30:59 AM: at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:18925:24)
11:30:59 AM: at file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:18885:26
11:30:59 AM: ​
11:30:59 AM: β€œbuild.command” failed
11:30:59 AM: ────────────────────────────────────────────────────────────────
11:30:59 AM: ​
11:30:59 AM: Error message
11:30:59 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:30:59 AM: ​
11:30:59 AM: Error location
11:30:59 AM: In Build command from Netlify app:
11:30:59 AM: npm run build
11:30:59 AM: ​
11:30:59 AM: Resolved config
11:30:59 AM: build:
11:30:59 AM: command: npm run build
11:30:59 AM: commandOrigin: ui
11:30:59 AM: publish: /opt/build/repo/dist
11:30:59 AM: publishOrigin: ui
11:30:59 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:30:59 AM: Failing build: Failed to build site
11:31:00 AM: Finished processing build request in 23.088s

This is due to case sensitivity. The filename is Footer.jsx

1 Like

Thank you! Deleted the files and pushed them to github again and it worked!