Building failed with message "Failed during stage "building site": Build script returned non-zero exit code: 2"

  • site name: https://amanoryd.es/

Hi everyone, today im having problems deploying my site, yesterday everything was perfect but today when I push a new page to my project im having the message in console:

6:15:08 PM: build-image version: fcb0c1b3ada6d25c1cb58e8bc514f5f23cc14f15 (focal)
6:15:08 PM: buildbot version: b01fe4bfba24ebbf2be94776e35d0c0d9decd607
6:15:08 PM: Building without cache
6:15:08 PM: Starting to prepare the repo for build
6:15:08 PM: No cached dependencies found. Cloning fresh repo
6:15:08 PM: git clone --filter=blob:none https://github.com/amanoryd/amanoryd.es
6:15:09 PM: Preparing Git Reference refs/heads/main
6:15:13 PM: Starting to install dependencies
6:15:14 PM: Python version set to 3.8
6:15:14 PM: Attempting Ruby version 2.7.2, read from environment
6:15:14 PM: Using Ruby version 2.7.2
6:15:15 PM: Started restoring cached go cache
6:15:15 PM: Finished restoring cached go cache
6:15:16 PM: go version go1.19.13 linux/amd64
6:15:17 PM: Using PHP version 8.0
6:15:18 PM: v18.19.0 is already installed.
6:15:18 PM: Now using node v18.19.0 (npm v10.2.3)
6:15:18 PM: Enabling Node.js Corepack
6:15:18 PM: Started restoring cached build plugins
6:15:18 PM: Finished restoring cached build plugins
6:15:18 PM: Started restoring cached corepack dependencies
6:15:18 PM: Finished restoring cached corepack dependencies
6:15:18 PM: No npm workspaces detected
6:15:18 PM: Started restoring cached node modules
6:15:18 PM: Finished restoring cached node modules
6:15:19 PM: Installing npm packages using npm version 10.2.3
6:15:21 PM: npm WARN deprecated @vitejs/plugin-react-refresh@1.3.6: This package has been deprecated in favor of @vitejs/plugin-react
6:15:23 PM: added 299 packages, and audited 300 packages in 5s
6:15:23 PM: 102 packages are looking for funding
6:15:23 PM: run npm fund for details
6:15:23 PM: found 0 vulnerabilities
6:15:23 PM: npm packages installed
6:15:24 PM: Successfully installed dependencies
6:15:24 PM: Starting build script
6:15:25 PM: Detected 1 framework(s)
6:15:25 PM: β€œvite” at version β€œ5.0.12”
6:15:25 PM: Section completed: initializing
6:15:26 PM: ​
6:15:26 PM: Netlify Build
6:15:26 PM: ────────────────────────────────────────────────────────────────
6:15:26 PM: ​
6:15:26 PM: ❯ Version
6:15:26 PM: @netlify/build 29.33.2
6:15:26 PM: ​
6:15:26 PM: ❯ Flags
6:15:26 PM: baseRelDir: true
6:15:26 PM: buildId: 65bbd17fef51f30535271775
6:15:26 PM: deployId: 65bbd17fef51f30535271777
6:15:26 PM: ​
6:15:26 PM: ❯ Current directory
6:15:26 PM: /opt/build/repo
6:15:26 PM: ​
6:15:26 PM: ❯ Config file
6:15:26 PM: No config file was defined: using default values.
6:15:26 PM: ​
6:15:26 PM: ❯ Context
6:15:26 PM: production
6:15:26 PM: ​
6:15:26 PM: Build command from Netlify app
6:15:26 PM: ────────────────────────────────────────────────────────────────
6:15:26 PM: ​
6:15:26 PM: $ npm run build
6:15:27 PM: > amanoryd.es@0.0.0 build
6:15:27 PM: > vite build
6:15:27 PM: vite v5.0.12 building for production…
6:15:27 PM: transforming…
6:15:27 PM: βœ“ 3 modules transformed.
6:15:27 PM: Could not resolve β€œ./src/Main” from β€œindex.jsx”
6:15:27 PM: file: /opt/build/repo/index.jsx
6:15:27 PM: error during build:
6:15:27 PM: RollupError: Could not resolve β€œ./src/Main” from β€œindex.jsx”
6:15:27 PM: at error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
6:15:27 PM: at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:18022:24)
6:15:27 PM: at file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:17982:26
6:15:27 PM: ​
6:15:27 PM: β€œbuild.command” failed
6:15:27 PM: ────────────────────────────────────────────────────────────────
6:15:27 PM: ​
6:15:27 PM: Error message
6:15:27 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
6:15:27 PM: ​
6:15:27 PM: Error location
6:15:27 PM: In Build command from Netlify app:
6:15:27 PM: npm run build
6:15:27 PM: ​
6:15:27 PM: Resolved config
6:15:27 PM: build:
6:15:27 PM: command: npm run build
6:15:27 PM: commandOrigin: ui
6:15:27 PM: environment:
6:15:27 PM: - VITE_PUBLIC_GOOGLE_MAPS_API_KEY
6:15:27 PM: - VITE_REACT_APP_API_INSTAGRAM_TOKEN
6:15:27 PM: publish: /opt/build/repo/dist
6:15:27 PM: publishOrigin: ui
6:15:27 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:15:27 PM: Failing build: Failed to build site
6:15:28 PM: Failed during stage β€œbuilding site”: Build script returned non-zero exit code: 2
6:15:28 PM: Finished processing build request in 19.645s

My project is created in Vite.js and in localhost runing β€œnpm run dev” works normal.

I readed about add β€œCLI” before de npm run build in Netlify but im questioning why i have to do that if my project was working normally.

Thanks,

File systems on Windows are case-insensitive, but the build systems on Netlify (which use Linux) are case-sensitive. Is your /src/Main lowercase possibly?

1 Like

Hi @AndrewH im Daniel, developer behind @amanoryd thanks for your coment.

Right now im at home, but at the office when i was working with this issue that was the first thing i checked in my code, that β€œMain” was β€œMain” and not β€œmain” in lowercase and it was β€œMain” right now at home when I made pull request of my code in my personal computer the file was β€œmain” WTF i dont know what happen, if I was tired or something but in any moment I made a change to this file name, and of course I always name my components firstletter Uppercase.

Anyway man thanks for your coment!

1 Like