Why my building is successfully and after gives a build error?

hi, first time here! I have try to build my project from a github repository and it gives me this message:

10:44:01 AM: Netlify Build                                                 
10:44:01 AM: ────────────────────────────────────────────────────────────────
10:44:01 AM: ​
10:44:01 AM: ❯ Version
10:44:01 AM:   @netlify/build 29.11.6
10:44:01 AM: ​
10:44:01 AM: ❯ Flags
10:44:01 AM:   baseRelDir: true
10:44:01 AM:   buildId: 6478a091330dda08e73fe06c
10:44:01 AM:   deployId: 6478a091330dda08e73fe06e
10:44:01 AM: ​
10:44:01 AM: ❯ Current directory
10:44:01 AM:   /opt/build/repo
10:44:01 AM: ​
10:44:01 AM: ❯ Config file
10:44:01 AM:   /opt/build/repo/netlify.toml
10:44:01 AM: ​
10:44:01 AM: ❯ Context
10:44:01 AM:   production
10:44:01 AM: ​
10:44:01 AM: build.command from netlify.toml                               
10:44:01 AM: ────────────────────────────────────────────────────────────────
10:44:01 AM: ​
10:44:01 AM: $ npm run build
10:44:01 AM: > web@0.0.0 build
10:44:01 AM: > tsc && vite build
10:44:05 AM: vite v4.3.8 building for production...
10:44:05 AM: transforming...
10:44:11 AM: ✓ 1089 modules transformed.
10:44:11 AM: rendering chunks...
10:44:11 AM: computing gzip size...
10:44:11 AM: dist/index.html                   0.46 kB │ gzip:   0.30 kB
10:44:11 AM: dist/assets/index-55fec1ff.css   11.42 kB │ gzip:   2.26 kB
10:44:11 AM: dist/assets/index-9f9f0fad.js   519.20 kB │ gzip: 171.71 kB
10:44:11 AM: 
10:44:11 AM: (!) Some chunks are larger than 500 kBs after minification. Consider:
10:44:11 AM: - Using dynamic import() to code-split the application
10:44:11 AM: - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
10:44:11 AM: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
10:44:11 AM: ✓ built in 6.47s
10:44:11 AM: ​
10:44:11 AM: (build.command completed in 10.2s)
10:44:11 AM: ​
10:44:14 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:44:14 AM: Failing build: Failed to build site
10:44:14 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:44:14 AM: Finished processing build request in 26.801s

i try to deploy manually and seems to works fine, its just when a try to do with a github repository, if anyone can help me i appreciate the help, thanks!

which of your sites is impacted?

@Marllon-Freitas If your build is throwing a warning (which it looks like it is - regarding the chunk size), then it will be because of this build fails on warning message.

Try changing your Build command from npm run build to CI= npm run build so that CI is set to false.

Hi Nathan, thanks for replying!
but I already use “CI= npm run build”

i try and i get the same result even with an environment variable
CI set to “false”

@Marllon-Freitas Sure, but if you look in your build log, you’ll see that’s not running because it’s preferencing the value you have in your netlify.toml file.