Error while deploying React App

10:12:19 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)
10:12:14 AM: Netlify Build
10:12:14 AM: ────────────────────────────────────────────────────────────────
10:12:14 AM: ​
10:12:14 AM: ❯ Version
10:12:14 AM: @netlify/build 29.20.6
10:12:14 AM: ​
10:12:14 AM: ❯ Flags
10:12:14 AM: baseRelDir: true
10:12:14 AM: buildId: 64e43c7ec1a82b1f9e1e75a0
10:12:14 AM: deployId: 64e43c7ec1a82b1f9e1e75a2
10:12:14 AM: ​
10:12:14 AM: ❯ Current directory
10:12:14 AM: /opt/build/repo
10:12:14 AM: ​
10:12:14 AM: ❯ Config file
10:12:14 AM: No config file was defined: using default values.
10:12:14 AM: ​
10:12:14 AM: ❯ Context
10:12:14 AM: production
10:12:14 AM: ​
10:12:14 AM: Build command from Netlify app
10:12:14 AM: ────────────────────────────────────────────────────────────────
10:12:14 AM: ​
10:12:14 AM: $ npm run build
10:12:14 AM: > internapp@0.0.0 build
10:12:14 AM: > tsc && vite build
10:12:17 AM: src/DepartmentListComponent.tsx(1,8): error TS1259: Module ‘/opt/build/repo/node_modules/@types/react/ts5.0/index’ can only be default-imported using the ‘allowSyntheticDefaultImports’ flag
10:12:17 AM: src/DepartmentListComponent.tsx(14,77): error TS7031: Binding element ‘departments’ implicitly has an ‘any’ type.
10:12:17 AM: src/DepartmentListComponent.tsx(50,24): error TS7006: Parameter ‘department’ implicitly has an ‘any’ type.
10:12:17 AM: src/main.tsx(1,8): error TS1259: Module ‘/opt/build/repo/node_modules/@types/react/ts5.0/index’ can only be default-imported using the ‘allowSyntheticDefaultImports’ flag
10:12:17 AM: src/main.tsx(2,8): error TS1192: Module ‘/opt/build/repo/node_modules/@types/react-dom/client’ has no default export.
10:12:17 AM: src/main.tsx(3,17): error TS2691: An import path cannot end with a ‘.tsx’ extension. Consider importing ‘./App.js’ instead.
10:12:17 AM: ​
10:12:17 AM: build.command failed
10:12:17 AM: ────────────────────────────────────────────────────────────────
10:12:17 AM: ​
10:12:17 AM: Error message
10:12:17 AM: Command failed with exit code 2: npm run build (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
10:12:17 AM: ​
10:12:17 AM: Error location
10:12:17 AM: In Build command from Netlify app:
10:12:17 AM: npm run build
10:12:17 AM: ​
10:12:17 AM: Resolved config
10:12:17 AM: build:
10:12:17 AM: command: npm run build
10:12:17 AM: commandOrigin: ui
10:12:17 AM: publish: /opt/build/repo/build
10:12:17 AM: publishOrigin: ui
10:12:19 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:12:19 AM: Failing build: Failed to build site
10:12:19 AM: Finished processing build request in 43.496s

Hi @rishavbhadani,

Thanks for reaching out!

Could you share the site name that you’re having issues with? Please let us know the site name such as example.netlify.app. Thank you!

Thank you for your reply but my issue is resolved now!