Having trouble deploying netlify React app from GitHub

Hello, I am having trouble deploying my website. It works normally on local but the second I try to deploy it, I get an error message. I have looked in the file mentioned in the error message and see no issue with it.

netlify site name: samuel-floyd.com (Idk if this is what you exactly want)

6:12:57 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
6:12:54 PM: Netlify Build                                                 
6:12:54 PM: ────────────────────────────────────────────────────────────────
6:12:54 PM: ​
6:12:54 PM: ❯ Version
6:12:54 PM:   @netlify/build 29.54.5
6:12:54 PM: ​
6:12:54 PM: ❯ Flags
6:12:54 PM:   accountId: 66b66d1db4d640653f245fcb
6:12:54 PM:   baseRelDir: true
6:12:54 PM:   buildId: 66f72d82a708befabd520e30
6:12:54 PM:   deployId: 66f72d82a708befabd520e32
6:12:54 PM: ​
6:12:54 PM: ❯ Current directory
6:12:54 PM:   /opt/build/repo
6:12:54 PM: ​
6:12:54 PM: ❯ Config file
6:12:54 PM:   No config file was defined: using default values.
6:12:54 PM: ​
6:12:54 PM: ❯ Context
6:12:54 PM:   production
6:12:54 PM: ​
6:12:54 PM: Build command from Netlify app                                
6:12:54 PM: ────────────────────────────────────────────────────────────────
6:12:54 PM: ​
6:12:54 PM: $ npm run build
6:12:54 PM: > websitetemplate@0.1.0 build
6:12:54 PM: > react-scripts build
6:12:55 PM: Creating an optimized production build...
6:12:56 PM: Failed to compile.
6:12:56 PM: 
6:12:56 PM: Module not found: Error: Can't resolve './context/navigation' in '/opt/build/repo/src'
6:12:56 PM: ​
6:12:56 PM: "build.command" failed                                        
6:12:56 PM: ────────────────────────────────────────────────────────────────
6:12:56 PM: ​
6:12:56 PM:   Error message
6:12:56 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
6:12:56 PM: ​
6:12:56 PM:   Error location
6:12:56 PM:   In Build command from Netlify app:
6:12:56 PM:   npm run build
6:12:56 PM: ​
6:12:56 PM:   Resolved config
6:12:56 PM:   build:
6:12:56 PM:     command: npm run build
6:12:56 PM:     commandOrigin: ui
6:12:56 PM:     publish: /opt/build/repo/build
6:12:56 PM:     publishOrigin: ui
6:12:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:12:57 PM: Failing build: Failed to build site
6:12:57 PM: Finished processing build request in 46.725s

Runtime: Not set

Base directory: /

Package directory: Not set

Build command: npm run build

Publish directory: build

Functions directory: netlify/functions

Deploy log visibility: Logs are public

Build status: Active

@FloydCoding The precise error is:

6:12:56 PM: Module not found: Error: Can't resolve './context/navigation' in '/opt/build/repo/src'

Check the file name and file references for your src/context/navigation file.

Pay particular attention to the case of letters, as Netlify’s build environment is case sensitive.

E.g. Make sure the file isn’t called src/context/Navigation etc.

If you find you can’t spot the issue yourself, please provide a link to the repository.

thank you for such a fast reply!

I have gone through and looked many times but could not find anything like you mentioned.

Here is a link to my repository…

@FloydCoding It’s precisely as I pointed out, the file is Navigation.js:

image

The reference to it is navigation:

navigation !== Navigation

Change either the reference to ./context/Navigation or the file to navigation.js

1 Like

Im so embarrassed!!! I swore I checked all of the files (on my computer) but didn’t realize the folder on my GitHub account had different capitalization. It was a lesson learned as I also had other folders with the wrong file names such as β€˜SideBar’ and β€˜Sidebar’.

Again, I appreciate your help a lot. You just relieved much frustration