Build failed due to a user error: Build script returned non-zero exit code: 2 and Command failed with exit code 1: npm run build

As the title implies, I ran into an error when trying to build my first site. I’m not sure what is causing the issue.

12:39:04 PM: build-image version: fcb0c1b3ada6d25c1cb58e8bc514f5f23cc14f15 (focal)
12:39:04 PM: buildbot version: 742cd4f739071a396139ba5020a96a927941b57d
12:39:04 PM: Fetching cached dependencies
12:39:04 PM: Failed to fetch cache, continuing with build
12:39:04 PM: Starting to prepare the repo for build
12:39:04 PM: No cached dependencies found. Cloning fresh repo
12:39:04 PM: git clone --filter=blob:none https://github.com/pixelizeog/eventlist
12:39:04 PM: Preparing Git Reference refs/heads/main
12:39:06 PM: Starting to install dependencies
12:39:06 PM: Python version set to 3.8
12:39:06 PM: Attempting Ruby version 2.7.2, read from environment
12:39:07 PM: Using Ruby version 2.7.2
12:39:07 PM: Started restoring cached go cache
12:39:07 PM: Finished restoring cached go cache
12:39:08 PM: go version go1.19.13 linux/amd64
12:39:09 PM: Using PHP version 8.0
12:39:09 PM: Attempting Node.js version "20.10.0" from .nvmrc
12:39:10 PM: Downloading and installing node v20.10.0...
12:39:10 PM: Downloading https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz...
12:39:10 PM: Computing checksum with sha256sum
12:39:10 PM: Checksums matched!
12:39:13 PM: Now using node v20.10.0 (npm v10.2.3)
12:39:13 PM: Enabling Node.js Corepack
12:39:13 PM: Started restoring cached build plugins
12:39:13 PM: Finished restoring cached build plugins
12:39:13 PM: Started restoring cached corepack dependencies
12:39:13 PM: Finished restoring cached corepack dependencies
12:39:13 PM: No npm workspaces detected
12:39:13 PM: Started restoring cached node modules
12:39:13 PM: Finished restoring cached node modules
12:39:13 PM: Installing npm packages using npm version 10.2.3
12:39:22 PM: added 615 packages, and audited 616 packages in 9s
12:39:22 PM: 200 packages are looking for funding
12:39:22 PM:   run `npm fund` for details
12:39:22 PM: found 0 vulnerabilities
12:39:22 PM: npm packages installed
12:39:22 PM: Successfully installed dependencies
12:39:22 PM: Starting build script
12:39:23 PM: Detected 1 framework(s)
12:39:23 PM: "astro" at version "4.4.0"
12:39:23 PM: Section completed: initializing
12:39:25 PM: ​
12:39:25 PM: Netlify Build                                                 
12:39:25 PM: ────────────────────────────────────────────────────────────────
12:39:25 PM: ​
12:39:25 PM: ❯ Version
12:39:25 PM:   @netlify/build 29.36.0
12:39:25 PM: ​
12:39:25 PM: ❯ Flags
12:39:25 PM:   baseRelDir: true
12:39:25 PM:   buildId: 65d8f44b61370c4b1887c9ae
12:39:25 PM:   deployId: 65d8f44b61370c4b1887c9b0
12:39:25 PM: ​
12:39:25 PM: ❯ Current directory
12:39:25 PM:   /opt/build/repo
12:39:25 PM: ​
12:39:25 PM: ❯ Config file
12:39:25 PM:   No config file was defined: using default values.
12:39:25 PM: ​
12:39:25 PM: ❯ Context
12:39:25 PM:   production
12:39:25 PM: ​
12:39:25 PM: Build command from Netlify app                                
12:39:25 PM: ────────────────────────────────────────────────────────────────
12:39:25 PM: ​
12:39:25 PM: $ npm run build
12:39:25 PM: > astwoah-stack@0.0.1 build
12:39:25 PM: > astro check && astro build
12:39:26 PM: 19:39:26 Types generated 206ms
12:39:26 PM: 19:39:26 [check] Getting diagnostics for Astro files in /opt/build/repo...
12:39:28 PM: src/middleware.ts:7:36 - error ts(7006): Parameter "next" implicitly has an "any" type.
12:39:28 PM: 7 export function onRequest(context, next) {
12:39:28 PM:                                      ~~~~
12:39:28 PM: src/middleware.ts:7:27 - error ts(7006): Parameter "context" implicitly has an "any" type.
12:39:28 PM: 7 export function onRequest(context, next) {
12:39:28 PM:                             ~~~~~~~
12:39:28 PM: src/middleware.ts:1:30 - error ts(7006): Parameter "context" implicitly has an "any" type.
12:39:28 PM: 1 function redirectIfNotAuthed(context) {
12:39:28 PM:                                ~~~~~~~
12:39:28 PM: src/middleware.ts:1:10 - warning ts(6133): "redirectIfNotAuthed" is declared but its value is never read.
12:39:28 PM: 1 function redirectIfNotAuthed(context) {
12:39:28 PM:            ~~~~~~~~~~~~~~~~~~~
12:39:28 PM: src/pages/api/htmx-partials/rick-roll.astro:8:3 - warning ts(6385): "frameborder" is deprecated.
12:39:28 PM: 8   frameborder="0"
12:39:28 PM:     ~~~~~~~~~~~
12:39:28 PM: Result (14 files): 
12:39:28 PM: - 3 errors
12:39:28 PM: - 0 warnings
12:39:28 PM: - 2 hints
12:39:28 PM: 
12:39:28 PM: ​
12:39:28 PM: "build.command" failed                                        
12:39:28 PM: ────────────────────────────────────────────────────────────────
12:39:28 PM: ​
12:39:28 PM:   Error message
12:39:28 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
12:39:28 PM: ​
12:39:28 PM:   Error location
12:39:28 PM:   In Build command from Netlify app:
12:39:28 PM:   npm run build
12:39:28 PM: ​
12:39:28 PM:   Resolved config
12:39:28 PM:   build:
12:39:28 PM:     command: npm run build
12:39:28 PM:     commandOrigin: ui
12:39:28 PM:     publish: /opt/build/repo/dist
12:39:28 PM:     publishOrigin: ui
12:39:29 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
12:39:29 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:39:29 PM: Failing build: Failed to build site
12:39:29 PM: Finished processing build request in 25.216s

As shown below there are 3 errors

If you look at the previous lines, you’ll see the errors.