Error message Command failed with exit code is confusing/misleading

The way that the Netlify build log so prominently displays Error message followed by Command failed with exit code ??? is fairly misleading, especially for less experienced developers.

It’s common that the root cause of the error be skipped over due to a misplaced fixation on the error code itself, which isn’t helped by the https://ntl.fyi/ link that throws users to related (but effectively random) forum search results.

It should be possible to reduce developer confusion, (and the number of support tickets generated), by creating better contextual error messaging along with links to documentation that provides known common causes and solutions.

Currently it’s common for confused developers to be unable to spot the “correct answer” within all the noise and they spend time reading and applying unrelated “fixes” which only serve to further confuse them, until they inevitably create a thread.

There should be less visual emphasis on the generic exit code.

I’ll provide just a few examples, but you could look at the vast majority of threads mentioning exit code to encounter the situation that I’ve outlined.

Examples

https://answers.netlify.com/t/command-failed-with-exit-code-1-npm-run-build-while-local-deployment-is-fine/114887

5:41:11 PM: Error message
5:41:11 PM: Command failed with exit code 1: npm run build (https ntl.fyi/exit-code-1)

Actual Error -> Warning thrown with default CI = true
https://answers.netlify.com/t/command-failed-with-exit-code-127/118616

9:47:23 AM: Error message
9:47:23 AM: Command failed with exit code 127: next build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)

Actual Error -> `bash: next: command not found` -> missing `package.json` -> incorrect base directory
https://answers.netlify.com/t/command-failed-with-exit-code-127-npm-run-build/115993

8:25:25 AM: Error message
8:25:25 AM: Command failed with exit code 127: npm install && CI= npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)

Actual Error -> `sh: 1: vite: not found` -> missing `package.json` -> incorrect base directory
https://answers.netlify.com/t/command-failed-with-exit-code-127-npm-run-build-https-ntl-fyi-exit-code-127-project-with-js-and-webpack-bild-bundler/112126

5:05:37 PM: Error message
5:05:37 PM: Command failed with exit code 127: npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)

Actual Error -> `sh: 1: webpack: not found` -> dependencies as devDependencies
https://answers.netlify.com/t/command-failed-with-exit-code-127-npm-run-build-hugo-nextjs-plugin/111463

4:29:47 PM: Error message
4:29:47 PM: Command failed with exit code 127: npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)

Actual Error -> `sh: 1: next: not found` -> dependency missing from `package.json`
https://answers.netlify.com/t/always-fail-to-build-react-app-command-failed-with-exit-code-127-npm-run-build-https-ntl-fyi-exit-code-127/110637https://answers.netlify.com/t/always-fail-to-build-react-app-command-failed-with-exit-code-127-npm-run-build-https-ntl-fyi-exit-code-127/110637

4:29:47 PM: Error message
4:29:47 PM: Command failed with exit code 1: npm run build (https ntl.fyi/exit-code-1)

Actual Error -> Module not found: Error: Can't resolve "axios" in "/opt/build/repo/src" -> dependency missing from `package.json`

-----

4:29:47 PM: Error message
4:29:47 PM: Command failed with exit code 127: npm run build

Actual Error -> sh: 1: react-scripts: not found -> dependency missing from `package.json`

Nathan! You must have read our minds. Part of our team is currently working on a project that will better guide our users around failed builds, and while the exit code is standard we are looking into that link you mention around forum results. While it won’t be released immediately, I’m sure you’ll be satisfied with the results.

We love and appreciate your feedback, you have such a huge impact in guiding us and being a voice for the users.

Thanks @charlottechhum, it’s great to hear that you’re looking to improve the developer experience surrounding build errors!

Tangentially related I did also spot that the existing links to https://ntl.fyi appear to be applied somewhat inconsistently, so just something to keep an eye out for with whatever new system is rolled out.

Hm… to clarify, do you mean not every failed build is receiving this ntl.fyi link? Or something else?

You can see it in the examples I copied and pasted above:

Command failed with exit code 1: ... (https ntl.fyi/exit-code-1)

Command failed with exit code 127: ... (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)

Command failed with exit code 127: ...

On closer inspection the ones with “Search results for…” are just due to the ntl.fyi link having been unfurled by discourse to show the page title, while the URL was malformed in the other.

The one in the screenshot for this post does appear to be missing a nty.fyi link though:

Which is odd considering it’s visible in other errors reporting exit code 127.

Ah, got it, got it. Thank you again!!