Gatsby 4 Build Issue Works Local but Fails on Netlify

Not sure why I keep running into this issue, deploying Gatsby to Netlify used to just work.
Gatsby V : ^4.5.4
Netlify ENV Vars: NODE_VERSION: 16.14.2
Netlify ENV Vars: RUBY_VERSION: 2.7.2
Build Image: Ubuntu Focal 20.04 (default)

Builds locally on my machine.
8:44:34 AM: β€œbuild.command” failed
8:44:34 AM: ────────────────────────────────────────────────────────────────
8:44:34 AM: ​
8:44:34 AM: Error message
8:44:34 AM: Command failed with exit code 127: gatsby build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
8:44:34 AM: ​
8:44:34 AM: Error location
8:44:34 AM: In Build command from Netlify app:
8:44:34 AM: gatsby build
8:44:34 AM: ​
8:44:34 AM: Resolved config
8:44:34 AM: build:
8:44:34 AM: command: gatsby build
8:44:34 AM: commandOrigin: ui
8:44:34 AM: environment:
8:44:34 AM: - NODE_VERSION
8:44:34 AM: - RUBY_VERSION
8:44:34 AM: publish: /opt/build/repo/public
8:44:34 AM: publishOrigin: ui
8:44:34 AM: functionsDirectory: /opt/build/repo/functions
8:44:35 AM: Caching artifacts

Not sure what to do? Any help would be appreciated.

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile: Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

This was due to my site living in a sub-directory of my repo so I failed to set the Base Directory in Netlify. Got it working now.