Command failed with exit code 1: CI= npm run build Help!

Site Name:

Hey Everyone,

Really banging my head against my desk on this one, I spent the last week building out a really awesome new feature for my site just to be hit by build issues on the final hurdle!

I am running into issues when running a build on netifly - I can run and build locally without issues, I am running on a mac so have some indication that this may be a case sensitive issues but I just cant see it

Here is my build Logs

8:46:25 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (
8:46:21 PM: Netlify Build                                                 
8:46:21 PM: ────────────────────────────────────────────────────────────────
8:46:21 PM: ​
8:46:21 PM: ❯ Version
8:46:21 PM:   @netlify/build 29.15.3
8:46:21 PM: ​
8:46:21 PM: ❯ Flags
8:46:21 PM:   baseRelDir: true
8:46:21 PM:   buildId: 64a9bce739b75e00082212cf
8:46:21 PM:   deployId: 64a9bce739b75e00082212d1
8:46:21 PM: ​
8:46:21 PM: ❯ Current directory
8:46:21 PM:   /opt/build/repo
8:46:21 PM: ​
8:46:21 PM: ❯ Config file
8:46:21 PM:   No config file was defined: using default values.
8:46:21 PM: ​
8:46:21 PM: ❯ Context
8:46:21 PM:   production
8:46:21 PM: ​
8:46:21 PM: Build command from Netlify app                                
8:46:21 PM: ────────────────────────────────────────────────────────────────
8:46:21 PM: ​
8:46:21 PM: $ CI= npm run build
8:46:21 PM: > waltzing-matilda@0.1.0 build
8:46:21 PM: > react-scripts build
8:46:23 PM: Creating an optimized production build...
8:46:25 PM: Failed to compile.
8:46:25 PM: 
8:46:25 PM: Module not found: Error: Can't resolve '../styles/images/chris.webp' in '/opt/build/repo/src/components'
8:46:25 PM: ​
8:46:25 PM: build.command failed                                        
8:46:25 PM: ────────────────────────────────────────────────────────────────
8:46:25 PM: ​
8:46:25 PM:   Error message
8:46:25 PM:   Command failed with exit code 1: CI= npm run build (
8:46:25 PM: ​
8:46:25 PM:   Error location
8:46:25 PM:   In Build command from Netlify app:
8:46:25 PM:   CI= npm run build
8:46:25 PM: ​
8:46:25 PM:   Resolved config
8:46:25 PM:   build:
8:46:25 PM:     command: CI= npm run build
8:46:25 PM:     commandOrigin: ui
8:46:25 PM:     environment:
8:46:25 PM:       - CI
8:46:25 PM:     publish: /opt/build/repo/build
8:46:25 PM:     publishOrigin: ui
8:46:25 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:46:25 PM: Failing build: Failed to build site
8:46:26 PM: Finished processing build request in 40.317s

Its mentions about not being able to find Chris.webp - have in this build tried to clean up my project directory so I think this is what has caused the issues - I have updated all my imports though and can this building locally without issue

I have pulled the aboutUs page out of the reorganised files to see if this helps but no avail but here are some screenshots of my file tree which include the images that the error mentions

I updated my build command on netifly to include CI = as I read that can help but still struggling!


@Chrisedwards96 What does that particular file look like in the repository?

from what I can see - it looks the same - everything has committed up to git

import React, { useState } from β€œreact”;
import β€œβ€¦/styles/AboutUs.css”;
import Chris from β€œβ€¦/styles/images/chris.webp”;
import Paul from β€œβ€¦/styles/images/paul.webp”;
import Matilda from β€œβ€¦/styles/images/matilda.webp”;
import PageDivider from β€œ./Common/PageDivider”;
import facadeLarge from β€œβ€¦/styles/images/youtube.webp”;
import facadeSmall from β€œβ€¦/styles/images/youtube-mob.webp”;

function YouTubeVideo({ videoId }) {
const [showVideo, setShowVideo] = useState(false);

const handleClick = () => {

return (

{!showVideo && (

YouTube video placeholder

{showVideo && (


I have just noticed on git there are discrepancies between the image name Chris.wepb to chris.webp - I will update these and hope it fixes - will update :slight_smile:

@Chrisedwards96 Yep, your issue is the repository has Chris.webp but you’re attempting to load chris.webp

It’s why I told you to check what’s in the repository, in the hopes that you would spot the likely discrepancy.

Your files locally looked ok to me, but Netlify isn’t going from what you have locally, it’s executing on what you have in the repository, so there was a chance you had something different in the repository than locally.

1 Like

Thanks so much!

I have successfully managed to get it deployed.

I ran a script

for file in *.webp; do
    if [[ "$file" =~ [[:upper:]] ]]; then
        git mv --force "$file" "$(echo $file | tr '[:upper:]' '[:lower:]')";

This script renames all .webp files in the current directory that have uppercase letters in their names to be all lowercase, then forced the rename on the git repo

updated my file paths and then the deployment work if anyone has the issue soon!

Thanks for pointing me to check git I didn’t realise that it was not recognising case sensitivity on my commits