During the building stage, I am getting a non-zero exit code 2 error. What could be causing this? How do I solve this issue?
I am deploying from a public gitHub repo I own and using the dist folder when setting up the deployment on Netlify.
Deploy Log under “Building” on Netlify:
12:49:26 PM: Netlify Build
12:49:26 PM: ────────────────────────────────────────────────────────────────
12:49:26 PM:
12:49:26 PM: ❯ Version
12:49:26 PM: @netlify/build 29.15.3
12:49:26 PM:
12:49:26 PM: ❯ Flags
12:49:26 PM: baseRelDir: true
12:49:26 PM: buildId: 64acdf312ac5c0360222224e
12:49:26 PM: deployId: 64acdf312ac5c03602222250
12:49:26 PM:
12:49:26 PM: ❯ Current directory
12:49:26 PM: /opt/build/repo
12:49:26 PM:
12:49:26 PM: ❯ Config file
12:49:26 PM: No config file was defined: using default values.
12:49:26 PM:
12:49:26 PM: ❯ Context
12:49:26 PM: production
12:49:26 PM:
12:49:26 PM: Build command from Netlify app
12:49:26 PM: ────────────────────────────────────────────────────────────────
12:49:26 PM:
12:49:26 PM: $ npm run build
12:49:27 PM: > random_quote_lc@1.0.0 build
12:49:27 PM: > vite build
12:49:27 PM: vite v3.2.7 building for production...
12:49:27 PM: <script src=dist/bundle.js> in /index.html can't be bundled without type=module attribute
transforming...
12:49:29 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
12:49:28 PM: ✓ 34 modules transformed.
12:49:28 PM: rendering chunks...
12:49:28 PM: dist/index.html 0.54 KiB
12:49:28 PM: dist/assets/index.28c2df18.css 227.35 KiB / gzip: 30.58 KiB
12:49:28 PM: dist/assets/index.644c0ae7.js 141.48 KiB / gzip: 45.78 KiB
12:49:28 PM:
12:49:28 PM: (build.command completed in 1.5s)
12:49:28 PM:
12:49:29 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:49:29 PM: Failing build: Failed to build site
12:49:30 PM: Finished processing build request in 14.636s