Build Fails on Netlify: “Command failed with exit code 1”

Hi everyone,

I’m hosting my website on Netlify, and recently, my builds started failing with the error Command failed with exit code 1. The issue appeared after I added some new dependencies to my project.

Here’s my setup:

  • Framework: React with Vite
  • Build command: npm run build
  • Publish directory: dist/

What I’ve observed:

  1. The build works perfectly on my local machine.

  2. The Netlify build log shows this error:
    Error: Command failed with exit code 1: npm run build

  3. There are warnings about missing peer dependencies, but I’m not sure if they’re related to the failure.

What I’ve tried so far:

  1. Cleared the build cache in Netlify and retried the deployment.
  2. Ensured all dependencies are correctly listed in package.json.
  3. Upgraded Node.js and npm versions in the Netlify build settings to match my local environment.
  4. Ran npm ci locally to confirm there are no dependency conflicts.

Questions I have:

  1. How can I debug the build failure further? Are there specific logs I should check on Netlify?
  2. Could the missing peer dependencies be causing the problem, and if so, how should I resolve them?
  3. Is there a better way to ensure my local and Netlify environments match exactly?

I’d really appreciate any guidance or tips to resolve this issue. Thanks in advance!

Hi @joeroot,

Thanks for reaching out!

We have a support guide on troubleshooting builds here:

Frequently encountered build issues are mentioned here:

Both Support Guides would be a great place to start with troubleshooting the build failures.

Additionally, you can share your site’s name (example sitename.netlify.app) and we can check on the Deploy logs to assist.

@joeroot This doesn’t help you answer your current issue, but it may help you debug on Netlify in future:

The exit code is not the error, it’s just the end result.

Take a look at this feature request that I made for more info:
https://answers.netlify.com/t/error-message-command-failed-with-exit-code-is-confusing-misleading/118887

Thank you for your response and the links to the troubleshooting guides. I’ll review those resources to see if they provide any insights. If you could take a look at the deploy logs and provide any additional information or suggestions, that would be greatly appreciated. Meanwhile, I’ll continue exploring the build logs and other recommendations in the support guides. Thanks again for your assistance!

You would need to post the logs here publicly, I don’t work for Netlify and have no visibility.