Build deploys locally but fails to deploy to GitHub

I am trying to deploy my site to GitHub but the build keeps failing. I am able to preview the build locally though. Any help resolving this would be appreciated! I looked at other similar topics and tried setting my Node Version in the settings but no dice!

Netlify Site ID: d710cdba-9d59-4cba-8f3c-0253e2229e70
Site name: shankarux
Domain: shankarux.com
Full build log:

4:18:14 PM: build-image version: ecdc8b770f4a0193fd3f258c1bc6029e681813a4 (focal)
4:18:14 PM: buildbot version: 778f625377bd173cd306eb0b71ebeb25fdfff620
4:18:14 PM: Fetching cached dependencies
4:18:14 PM: Failed to fetch cache, continuing with build
4:18:14 PM: Starting to prepare the repo for build
4:18:15 PM: No cached dependencies found. Cloning fresh repo
4:18:15 PM: git clone --filter=blob:none https://github.com/that90sdesigner/personalSite
4:18:15 PM: Preparing Git Reference refs/heads/main
4:18:17 PM: Starting to install dependencies
4:18:17 PM: Python version set to 3.8
4:18:17 PM: Attempting Ruby version 2.7.2, read from environment
4:18:18 PM: Using Ruby version 2.7.2
4:18:18 PM: Started restoring cached go cache
4:18:18 PM: Finished restoring cached go cache
4:18:19 PM: go version go1.19.13 linux/amd64
4:18:20 PM: Using PHP version 8.0
4:18:22 PM: Downloading and installing node v20.16.0...
4:18:22 PM: Downloading https://nodejs.org/dist/v20.16.0/node-v20.16.0-linux-x64.tar.xz...
4:18:22 PM: Computing checksum with sha256sum
4:18:22 PM: Checksums matched!
4:18:24 PM: Now using node v20.16.0 (npm v10.8.1)
4:18:24 PM: Enabling Node.js Corepack
4:18:24 PM: Started restoring cached build plugins
4:18:24 PM: Finished restoring cached build plugins
4:18:24 PM: Started restoring cached corepack dependencies
4:18:24 PM: Finished restoring cached corepack dependencies
4:18:24 PM: No npm workspaces detected
4:18:24 PM: Started restoring cached node modules
4:18:24 PM: Finished restoring cached node modules
4:18:24 PM: Installing npm packages using npm version 10.8.1
4:18:29 PM: added 413 packages, and audited 414 packages in 4s
4:18:29 PM: 164 packages are looking for funding
4:18:29 PM:   run `npm fund` for details
4:18:29 PM: found 0 vulnerabilities
4:18:29 PM: npm packages installed
4:18:29 PM: Successfully installed dependencies
4:18:29 PM: Starting build script
4:18:30 PM: Detected 1 framework(s)
4:18:30 PM: "astro" at version "4.13.3"
4:18:30 PM: Section completed: initializing
4:18:32 PM: ​
4:18:32 PM: Netlify Build                                                 
4:18:32 PM: ────────────────────────────────────────────────────────────────
4:18:32 PM: ​
4:18:32 PM: ❯ Version
4:18:32 PM:   @netlify/build 29.53.0
4:18:32 PM: ​
4:18:32 PM: ❯ Flags
4:18:32 PM:   accountId: 63797b4e142bf24f7541a553
4:18:32 PM:   baseRelDir: true
4:18:32 PM:   buildId: 66b7f52c09978a00082c0103
4:18:32 PM:   deployId: 66b7f52c09978a00082c0105
4:18:32 PM: ​
4:18:32 PM: ❯ Current directory
4:18:32 PM:   /opt/build/repo
4:18:32 PM: ​
4:18:32 PM: ❯ Config file
4:18:32 PM:   No config file was defined: using default values.
4:18:32 PM: ​
4:18:32 PM: ❯ Context
4:18:32 PM:   production
4:18:32 PM: ​
4:18:32 PM: Build command from Netlify app                                
4:18:32 PM: ────────────────────────────────────────────────────────────────
4:18:32 PM: ​
4:18:32 PM: $ npm run build
4:18:32 PM: > latest@0.0.1 build
4:18:32 PM: > astro check && astro build
4:18:33 PM: 23:18:33 [types] Generated 43ms
4:18:33 PM: 23:18:33 [check] Getting diagnostics for Astro files in /opt/build/repo...
4:18:34 PM: src/components/BlogPost.astro:3:7 - warning ts(6198): All destructured elements are unused.
4:18:34 PM: 3 const { date, url, title } = Astro.props;
4:18:34 PM:         ~~~~~~~~~~~~~~~~~~~~
4:18:34 PM: src/components/Card.astro:8:15 - error ts(2339): Property 'img' does not exist on type 'Props'.
4:18:34 PM: 8 const { href, img, title, body } = Astro.props;
4:18:34 PM:                 ~~~
4:18:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:18:35 PM: src/layouts/MarkdownPostLayout.astro:14:2 - error ts(2322): Type '{}' is not assignable to type 'IntrinsicAttributes & Props'.
4:18:35 PM:   Property 'title' is missing in type '{}' but required in type 'Props'.
4:18:35 PM: 14 <Layout/>
4:18:35 PM:     ~~~~~~
4:18:35 PM: src/pages/blog.astro:12:2 - error ts(2322): Type '{ children: any; }' is not assignable to type 'IntrinsicAttributes & Props'.
4:18:35 PM:   Property 'title' is missing in type '{ children: any; }' but required in type 'Props'.
4:18:35 PM: 12 <Layout>
4:18:35 PM:     ~~~~~~
4:18:35 PM: src/pages/index.astro:63:4 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
4:18:35 PM:   Property 'img' does not exist on type 'IntrinsicAttributes & Props'.
4:18:35 PM: 63    img="/project-images/project-merchant-center.png"
4:18:35 PM:       ~~~
4:18:35 PM: src/pages/index.astro:56:3 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
4:18:35 PM:   Property 'img' does not exist on type 'IntrinsicAttributes & Props'.
4:18:35 PM: 56   img="/project-images/project-gmail.png"
4:18:35 PM:      ~~~
4:18:35 PM: src/pages/index.astro:49:5 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
4:18:35 PM:   Property 'img' does not exist on type 'IntrinsicAttributes & Props'.
4:18:35 PM: 49     img="/project-images/project-year-in-books.png"
4:18:35 PM:        ~~~
4:18:35 PM: Result (12 files): 
4:18:35 PM: - 6 errors
4:18:35 PM: - 0 warnings
4:18:35 PM: - 1 hint
4:18:35 PM: 
4:18:35 PM: ​
4:18:35 PM: "build.command" failed                                        
4:18:35 PM: ────────────────────────────────────────────────────────────────
4:18:35 PM: ​
4:18:35 PM:   Error message
4:18:35 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
4:18:35 PM: ​
4:18:35 PM:   Error location
4:18:35 PM:   In Build command from Netlify app:
4:18:35 PM:   npm run build
4:18:35 PM: ​
4:18:35 PM:   Resolved config
4:18:35 PM:   build:
4:18:35 PM:     command: npm run build
4:18:35 PM:     commandOrigin: ui
4:18:35 PM:     publish: /opt/build/repo/dist
4:18:35 PM:     publishOrigin: ui
4:18:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:18:35 PM: Failing build: Failed to build site
4:18:35 PM: Finished processing build request in 21.251s```

But can you build it locally?
What happens when you run npm run build locally?

What version did you try to set?
The build log shows:

4:18:24 PM: Now using node v20.16.0 (npm v10.8.1)

When i run npm run build locally, I get the following:

> latest@0.0.1 build
> astro check && astro build

17:06:07 [vite] Re-optimizing dependencies because vite config has changed
17:06:07 [types] Generated 46ms
17:06:07 [check] Getting diagnostics for Astro files in /Users/shankarbalasubramanian/Documents/GitHub/personalSite...
src/env.d.ts:2:35 - error ts(1109): Expression expected.

2 <reference types="astro/client" />
                                    
src/env.d.ts:2:34 - error ts(1109): Expression expected.

2 <reference types="astro/client" />
                                   ~
src/env.d.ts:2:17 - error ts(1005): ';' expected.

2 <reference types="astro/client" />
                  ~
src/env.d.ts:2:12 - error ts(1005): '>' expected.

2 <reference types="astro/client" />
             ~~~~~
src/env.d.ts:1:41 - error ts(1109): Expression expected.

1 <reference path="../.astro/types.d.ts" />
                                          ~
src/env.d.ts:1:16 - error ts(1005): ';' expected.

1 <reference path="../.astro/types.d.ts" />
                 ~
src/env.d.ts:1:12 - error ts(1005): '>' expected.

1 <reference path="../.astro/types.d.ts" />
             ~~~~

src/components/blogpost.astro:3:7 - warning ts(6198): All destructured elements are unused.

3 const { date, url, title } = Astro.props;
        ~~~~~~~~~~~~~~~~~~~~

src/components/card.astro:8:15 - error ts(2339): Property 'img' does not exist on type 'Props'.

8 const { href, img, title, body } = Astro.props;
                ~~~

src/layouts/MarkdownPostLayout.astro:14:2 - error ts(2322): Type '{}' is not assignable to type 'IntrinsicAttributes & Props'.
  Property 'title' is missing in type '{}' but required in type 'Props'.

14 <Layout/>
    ~~~~~~
src/layouts/MarkdownPostLayout.astro:5:20 - error ts(1149): File name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/layout.astro' differs from already included file name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/Layout.astro' only in casing.
  The file is in the program because:

5 import Layout from './layout.astro';
                     ~~~~~~~~~~~~~~~~

src/pages/blog.astro:12:2 - error ts(2322): Type '{ children: any; }' is not assignable to type 'IntrinsicAttributes & Props'.
  Property 'title' is missing in type '{ children: any; }' but required in type 'Props'.

12 <Layout>
    ~~~~~~
src/pages/blog.astro:3:20 - error ts(1149): File name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/layout.astro' differs from already included file name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/Layout.astro' only in casing.
  The file is in the program because:

3 import Layout from '../layouts/layout.astro';
                     ~~~~~~~~~~~~~~~~~~~~~~~~~

src/pages/index.astro:63:4 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
  Property 'img' does not exist on type 'IntrinsicAttributes & Props'.

63    img="/project-images/project-merchant-center.png"
      ~~~
src/pages/index.astro:56:3 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
  Property 'img' does not exist on type 'IntrinsicAttributes & Props'.

56   img="/project-images/project-gmail.png"
     ~~~
src/pages/index.astro:49:5 - error ts(2322): Type '{ href: string; img: string; title: string; body: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
  Property 'img' does not exist on type 'IntrinsicAttributes & Props'.

49     img="/project-images/project-year-in-books.png"
       ~~~
src/pages/index.astro:3:20 - error ts(1149): File name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/layout.astro' differs from already included file name '/Users/shankarbalasubramanian/Documents/GitHub/personalSite/src/layouts/Layout.astro' only in casing.
  The file is in the program because:

3 import Layout from '../layouts/layout.astro';
                     ~~~~~~~~~~~~~~~~~~~~~~~~~

Result (11 files): 
- 16 errors
- 0 warnings
- 1 hint

@shankarux If you didn’t spot it, those are the same errors.

For example:

and

If your build doesn’t work locally, it won’t work on Netlify either.

With the same messages occurring locally, you know it’s not caused by Netlify’s systems.

You need to debug your own project and once your build runs correctly on your local system, you can expect it to run correctly on Netlify too.

They all look like TypeScript related linting errors to me, and point to things in your code that it wants you to fix.