React Deploy Failed @ npm run build error code ELIFECYCLE errno 1 Cannot find file

Hi, I’m trying to deploy an app React app created with create-react-app. It keeps failing after it tries to run the build command.

See log below. It seems like it not able to find the .svg file even though it is there. Letter casing is correct and it works locally.

Anybody know why it is Failing even though it’s working locally. I’m on a MAC OS.

Thanks in advance for your help!

log script below:

8:29:36 PM: Verify run directory
8:29:37 PM: ​
8:29:37 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:29:37 PM: β”‚ Netlify Build β”‚
8:29:37 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:29:37 PM: ​
8:29:37 PM: ❯ Version
8:29:37 PM: @netlify/build 3.3.0
8:29:37 PM: ​
8:29:37 PM: ❯ Flags
8:29:37 PM: deployId: 5f4ef54fe99df01768fd70ff
8:29:37 PM: mode: buildbot
8:29:37 PM: ​
8:29:37 PM: ❯ Current directory
8:29:37 PM: /opt/build/repo
8:29:37 PM: ​
8:29:37 PM: ❯ Config file
8:29:37 PM: No config file was defined: using default values.
8:29:37 PM: ​
8:29:37 PM: ❯ Context
8:29:37 PM: production
8:29:37 PM: ​
8:29:37 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:29:37 PM: β”‚ 1. Build command from Netlify app β”‚
8:29:37 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:29:37 PM: ​
8:29:37 PM: $ npm run build
8:29:37 PM: > crwn-clothing@0.1.0 build /opt/build/repo
8:29:37 PM: > react-scripts build
8:29:39 PM: Creating an optimized production build…
8:29:45 PM: Failed to compile.
8:29:45 PM:
8:29:45 PM: ./src/components/header/header.component.jsx
8:29:45 PM: Cannot find file β€˜β€¦/…/assets/crown.svg’ in β€˜./src/components/header’.
8:29:45 PM: npm ERR! code ELIFECYCLE
8:29:45 PM: npm ERR! errno 1
8:29:45 PM: npm ERR! crwn-clothing@0.1.0 build: react-scripts build
8:29:45 PM: npm ERR! Exit status 1
8:29:45 PM: npm ERR!
8:29:45 PM: npm ERR! Failed at the crwn-clothing@0.1.0 build script.
8:29:45 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
8:29:45 PM: npm ERR! A complete log of this run can be found in:
8:29:45 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-09-02T01_29_45_798Z-debug.log
8:29:45 PM:
8:29:45 PM: If the build failed with a warning about β€œprocess.env.CI = true”, this is due to β€œcreate-react-app” treating warnings as errors when in CI. In order to fix this problem, please either:
8:29:45 PM: - Fix the issues highlighted by the warnings above.
8:29:45 PM: - Or modify the β€œscripts.build” command in your β€œpackage.json” from β€œreact-scripts build” to β€œCI= react-scripts build”
8:29:45 PM: More information can be found at https://docs.netlify.com/configure-builds/troubleshooting-tips/#build-fails-on-warning-message
8:29:45 PM: ​
8:29:45 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:29:45 PM: β”‚ β€œbuild.command” failed β”‚
8:29:45 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:29:45 PM: ​
8:29:45 PM: Error message
8:29:45 PM: Command failed with exit code 1: npm run build
8:29:45 PM: ​
8:29:45 PM: Error location
8:29:45 PM: In Build command from Netlify app:
8:29:45 PM: npm run build
8:29:45 PM: ​
8:29:45 PM: Resolved config
8:29:45 PM: build:
8:29:45 PM: command: npm run build
8:29:45 PM: commandOrigin: ui
8:29:45 PM: publish: /opt/build/repo/dist

Howdy,

it’s definitely related to us not being able to find the file :expressionless:

If it’s not case (you are sure? that is the cause of the problem 99.99% of the time…) is it maybe the path? :thinking:

just in case… (that was a terrible joke)

Hi,

I ended up just manually uploading the build file and it worked. I still don’t know why it’s failing when I try to run the build and upload through GitHub. If anyone else has this problem, a work around is to run the build locally and then just manually upload the folder instead of using GitHub.

hmm. that’s super odd! there should be a way to get this working via CI. If you run in to this problem again, do let us know and we can poke at it some more.

Hi,

I have the same problem

9:34:08 PM: ./src/index.js
9:34:08 PM: Cannot find file β€˜./app’ in β€˜./src’.

Here is how I do my import

import {App} from β€˜./app’;

I’ve tried to add the node and npm version I’m using in a netlify.toml file but it still doesn’t work.

Uploading the build folder works fine

I found the issue. For whatever reason, git was keeping track of app.js as App.js. Thus, the file uploaded via Github to Netlify was nammed App.js.

To solve this I did: git rm -r --cached src/App.js, git add src/app.js and it worked.

1 Like

ahh! the issue was case. more on that here:

1 Like