“build.command” failed Netflify not building (FIX)

One day I was trying to deploy github repository on Netlify and I got a deployment error message with “build.command” failed │along with an error message Command failed with exit code 1: npm run build. I spent hours trying to fix this issue. I tried installing and building npm again, trying all the solutions from StackOverflow and Netlify forum and eventually I came up with a simple solution which I felt like sharing here with you all.

So in this post, I’m gonna show how I fixed a Netlify build error which is Command failed with exit code 1: npm run build. As you see, as of June 15, 2020, Netlify started some changes by adding the environment variable CI to build environments, with the value of true. So the default, deployment setting might not work with your github projects.

Command failed with exit code 1: npm run build

The solution was simply updating the build command settings on Netlify with the following command:

CI= npm run build

Steps to resolve the issue

  1. Go To your Netlify account and access the Deployment Failed section. Then click Deployment Settings Button.

2. Locate Build & deploy section on your top-left and click Edit settings under Build settings section.

3. Now update the default Build Command field with CI= npm run build command and save settings.

4. Go back to your failed deployment section and under Retry deployment, hit Clear cache and deployment site.

This step will get your netlify app published. Happy coding.