Build error during deployment

I’m having a problem deploying from my git repo. The problem occurs during the build. I’ve previously deployed several react-app repositories without no issues, but this current build gives an error. I’ve tried every solution I could find with no success.

Here is the complete error log:

11:02:46 AM: Netlify Build                                                 
11:02:46 AM: ────────────────────────────────────────────────────────────────
11:02:46 AM: ​
11:02:46 AM: ❯ Version
11:02:46 AM:   @netlify/build 29.11.7
11:02:46 AM: ​
11:02:46 AM: ❯ Flags
11:02:46 AM:   baseRelDir: true
11:02:46 AM:   buildId: 647c61046434600008c5b20b
11:02:46 AM:   deployId: 647c61046434600008c5b20d
11:02:46 AM: ​
11:02:46 AM: ❯ Current directory
11:02:46 AM:   /opt/build/repo/client
11:02:46 AM: ​
11:02:46 AM: ❯ Config file
11:02:46 AM:   /opt/build/repo/client/netlify.toml
11:02:46 AM: ​
11:02:46 AM: ❯ Context
11:02:46 AM:   production
11:02:46 AM: ​
11:02:46 AM: build.command from netlify.toml                               
11:02:46 AM: ────────────────────────────────────────────────────────────────
11:02:46 AM: ​
11:02:46 AM: $ CI= npm run build
11:02:47 AM: > nike3d@0.0.0 build
11:02:47 AM: > vite build
11:02:47 AM: vite v4.3.9 building for production...
11:02:47 AM: transforming...
11:02:52 AM: Use of eval in "node_modules/@chevrotain/utils/lib/src/to-fast-properties.js" is strongly discouraged as it poses security risks and may cause issues with minification.
11:02:53 AM: ✓ 1174 modules transformed.
11:02:53 AM: Generated an empty chunk: "bidi-js".
11:02:53 AM: Generated an empty chunk: "camera-controls".
11:02:53 AM: Generated an empty chunk: "chevrotain".
11:02:53 AM: Generated an empty chunk: "detect-gpu".
11:02:53 AM: Generated an empty chunk: "fflate".
11:02:53 AM: Generated an empty chunk: "ktx-parse".
11:02:53 AM: Generated an empty chunk: "lodash".
11:02:53 AM: Generated an empty chunk: "lodash.clamp".
11:02:53 AM: Generated an empty chunk: "lodash.omit".
11:02:53 AM: Generated an empty chunk: "lodash.pick".
11:02:53 AM: Generated an empty chunk: "meshline".
11:02:53 AM: Generated an empty chunk: "mmd-parser".
11:02:53 AM: Generated an empty chunk: "opentype.js".
11:02:53 AM: Generated an empty chunk: "potpack".
11:02:53 AM: Generated an empty chunk: "prop-types".
11:02:53 AM: Generated an empty chunk: "react-merge-refs".
11:02:53 AM: Generated an empty chunk: "regexp-to-ast".
11:02:53 AM: Generated an empty chunk: "stats.js".
11:02:53 AM: Generated an empty chunk: "three-mesh-bvh".
11:02:53 AM: Generated an empty chunk: "troika-three-text".
11:02:53 AM: Generated an empty chunk: "troika-three-utils".
11:02:53 AM: Generated an empty chunk: "troika-worker-utils".
11:02:53 AM: Generated an empty chunk: "webgl-sdf-generator".
11:02:53 AM: Generated an empty chunk: "zstddec".
11:02:53 AM: rendering chunks...
11:02:53 AM: computing gzip size...
11:02:53 AM: dist/index.html                                1.66 kB │ gzip:   0.52 kB
11:02:53 AM: dist/assets/index-3baab88a.css                 7.42 kB │ gzip:   2.12 kB
11:02:53 AM: dist/assets/fflate-4ed993c7.js                 0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/lodash.omit-4ed993c7.js            0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/potpack-4ed993c7.js                0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/mmd-parser-4ed993c7.js             0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/meshline-4ed993c7.js               0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/react-merge-refs-4ed993c7.js       0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/lodash.clamp-4ed993c7.js           0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/detect-gpu-4ed993c7.js             0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/camera-controls-4ed993c7.js        0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/lodash.pick-4ed993c7.js            0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/opentype.js-4ed993c7.js            0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/prop-types-4ed993c7.js             0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/bidi-js-4ed993c7.js                0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/chevrotain-4ed993c7.js             0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/ktx-parse-4ed993c7.js              0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/lodash-4ed993c7.js                 0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/regexp-to-ast-4ed993c7.js          0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/zstddec-4ed993c7.js                0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/webgl-sdf-generator-4ed993c7.js    0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/troika-worker-utils-4ed993c7.js    0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/troika-three-utils-4ed993c7.js     0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/three-mesh-bvh-4ed993c7.js         0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/stats.js-4ed993c7.js               0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/troika-three-text-4ed993c7.js      0.00 kB │ gzip:   0.02 kB
11:02:53 AM: dist/assets/@react-spring-99a9aed5.js          0.03 kB │ gzip:   0.05 kB
11:02:55 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:02:53 AM: dist/assets/react-composer-99a9aed5.js         0.03 kB │ gzip:   0.05 kB
11:02:53 AM: dist/assets/@use-gesture-99a9aed5.js           0.03 kB │ gzip:   0.05 kB
11:02:53 AM: dist/assets/@chevrotain-39b5b250.js            0.12 kB │ gzip:   0.13 kB
11:02:53 AM: dist/assets/@babel-98964cd2.js                 0.24 kB │ gzip:   0.19 kB
11:02:53 AM: dist/assets/debounce-6284fd2f.js               0.50 kB │ gzip:   0.30 kB
11:02:53 AM: dist/assets/suspend-react-00b64780.js          0.88 kB │ gzip:   0.47 kB
11:02:53 AM: dist/assets/zustand-b2af9d58.js                1.59 kB │ gzip:   0.85 kB
11:02:53 AM: dist/assets/its-fine-1bc6d9bc.js               1.85 kB │ gzip:   0.95 kB
11:02:53 AM: dist/assets/react-use-measure-d29e657e.js      2.54 kB │ gzip:   1.10 kB
11:02:53 AM: dist/assets/scheduler-765c72db.js              4.10 kB │ gzip:   1.78 kB
11:02:53 AM: dist/assets/maath-47086a7c.js                  6.81 kB │ gzip:   2.88 kB
11:02:53 AM: dist/assets/react-1d8b2501.js                  7.65 kB │ gzip:   2.87 kB
11:02:53 AM: dist/assets/index-52b75254.js                 10.36 kB │ gzip:   4.20 kB
11:02:53 AM: dist/assets/@react-three-49de9140.js          40.72 kB │ gzip:  15.39 kB
11:02:53 AM: dist/assets/three-stdlib-7c170d20.js          76.96 kB │ gzip:  23.10 kB
11:02:53 AM: dist/assets/react-reconciler-6b9bfd39.js      90.68 kB │ gzip:  27.95 kB
11:02:53 AM: dist/assets/react-dom-9c72fde2.js            134.06 kB │ gzip:  43.19 kB
11:02:53 AM: dist/assets/three-21a11f10.js                631.38 kB │ gzip: 162.26 kB
11:02:53 AM: ✓ built in 6.24s
11:02:53 AM: ​
11:02:53 AM: (build.command completed in 6.9s)
11:02:53 AM: ​
11:02:55 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:02:55 AM: Failing build: Failed to build site
11:02:55 AM: Finished processing build request in 34.6s

@CharlesXstorm Have you tried running your npm run build locally?

so, I added some configurations to my vite.config file and it did build successfully locally, though it gave some warnings about adjusting the chunk size limit. I redeployed on here, but it seems Netlify’s build sees warnings as errors and it fails immediately.

Here is the complete error log:

12:35:25 PM: Netlify Build                                                 
12:35:25 PM: ────────────────────────────────────────────────────────────────
12:35:25 PM: ​
12:35:25 PM: ❯ Version
12:35:25 PM:   @netlify/build 29.11.7
12:35:25 PM: ​
12:35:25 PM: ❯ Flags
12:35:25 PM:   baseRelDir: true
12:35:25 PM:   buildId: 647c76bc0939cc0008b51141
12:35:25 PM:   deployId: 647c76bc0939cc0008b51143
12:35:25 PM: ​
12:35:25 PM: ❯ Current directory
12:35:25 PM:   /opt/build/repo/client
12:35:25 PM: ​
12:35:25 PM: ❯ Config file
12:35:25 PM:   /opt/build/repo/client/netlify.toml
12:35:25 PM: ​
12:35:25 PM: ❯ Context
12:35:25 PM:   production
12:35:25 PM: ​
12:35:25 PM: build.command from netlify.toml                               
12:35:25 PM: ────────────────────────────────────────────────────────────────
12:35:25 PM: ​
12:35:25 PM: $ CI= npm run build
12:35:25 PM: > nike3d@0.0.0 build
12:35:25 PM: > vite build
12:35:26 PM: vite v4.3.9 building for production...
12:35:26 PM: transforming...
12:35:30 PM: Use of eval in "node_modules/@chevrotain/utils/lib/src/to-fast-properties.js" is strongly discouraged as it poses security risks and may cause issues with minification.
12:35:31 PM: ✓ 1174 modules transformed.
12:35:32 PM: rendering chunks...
12:35:32 PM: computing gzip size...
12:35:32 PM: dist/index.html                     0.53 kB │ gzip:   0.33 kB
12:35:32 PM: dist/assets/index-6a36915c.css      7.50 kB │ gzip:   2.16 kB
12:35:32 PM: dist/assets/index-fc5a56dd.js      10.00 kB │ gzip:   4.04 kB
12:35:32 PM: dist/assets/vendor-f3859ba9.js  1,001.14 kB │ gzip: 280.61 kB
12:35:32 PM: 
12:35:32 PM: (!) Some chunks are larger than 700 kBs after minification. Consider:
12:35:32 PM: - Using dynamic import() to code-split the application
12:35:32 PM: - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
12:35:32 PM: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
12:35:32 PM: ✓ built in 6.18s
12:35:32 PM: ​
12:35:32 PM: (build.command completed in 7s)
12:35:32 PM: ​
12:35:34 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
12:35:33 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:35:34 PM: Failing build: Failed to build site
12:35:34 PM: Finished processing build request in 33.694s

That is the case by default, but these lines in your log:

12:35:25 PM: build.command from netlify.toml                               
12:35:25 PM: ────────────────────────────────────────────────────────────────
12:35:25 PM: ​
12:35:25 PM: $ CI= npm run build

Indicates that your netlify.toml build command is CI= npm run build, which disables that behavior.

It’s setting the CI value to false

See:

The error is in the deploying stage: Netlify App

Error message:

Deploy did not succeed: Deploy directory 'client/build' does not exist

‘client/build’ does not exist, isn’t that because the build actually didn’t complete? or is there something I’m missing?

since CI= false in my build, what could be the problem?

vite outputs in dist by default. This can even be seen in the logs:

1 Like

rightfully so.
I changed the publish directory in the netlify.toml file from “publish = build” to ''publish = /dist".
Thank you for the help.