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`