Build error when trying to deploy SvelteKit app

Site name: reliable-tartufo-728ea4.netlify.app

I’m getting this error when trying to deploy my SvelteKit app.
ENOENT: no such file or directory, open ‘build/_redirects’

I’m doing it the exact same way as I always do.
See deploy log below, what could cause this?

4:35:45 PM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/robindelaater/builds
4:36:03 PM: Build ready to start
4:36:04 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
4:36:04 PM: build-image tag: v4.8.0
4:36:04 PM: buildbot version: e58b6be665675c0f99b33132a8c1eec1f775eba1
4:36:05 PM: Building without cache
4:36:05 PM: Starting to prepare the repo for build
4:36:05 PM: No cached dependencies found. Cloning fresh repo
4:36:05 PM: git clone https://github.com/robindelaater/sovmedia
4:36:06 PM: Preparing Git Reference refs/heads/main
4:36:06 PM: Parsing package.json dependencies
4:36:07 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'functions' versus 'functions/' in the Netlify UI
4:36:07 PM: Starting build script
4:36:07 PM: Installing dependencies
4:36:07 PM: Python version set to 2.7
4:36:08 PM: v16.14.2 is already installed.
4:36:08 PM: Now using node v16.14.2 (npm v8.5.0)
4:36:08 PM: Started restoring cached build plugins
4:36:08 PM: Finished restoring cached build plugins
4:36:09 PM: Attempting ruby version 2.7.2, read from environment
4:36:10 PM: Using ruby version 2.7.2
4:36:10 PM: Using PHP version 8.0
4:36:11 PM: No npm workspaces detected
4:36:11 PM: Started restoring cached node modules
4:36:11 PM: Finished restoring cached node modules
4:36:11 PM: Installing NPM modules using NPM version 8.5.0
4:36:16 PM: > sovmedia@0.0.1 prepare
4:36:16 PM: > svelte-kit sync
4:36:17 PM: added 221 packages, and audited 222 packages in 5s
4:36:17 PM: 40 packages are looking for funding
4:36:17 PM:   run `npm fund` for details
4:36:17 PM: found 0 vulnerabilities
4:36:17 PM: NPM modules installed
4:36:17 PM: Started restoring cached go cache
4:36:17 PM: Finished restoring cached go cache
4:36:17 PM: go version go1.16.5 linux/amd64
4:36:17 PM: go version go1.16.5 linux/amd64
4:36:17 PM: Installing missing commands
4:36:17 PM: Verify run directory
4:36:19 PM: ​
4:36:19 PM: ────────────────────────────────────────────────────────────────
4:36:19 PM:   Netlify Build                                                 
4:36:19 PM: ────────────────────────────────────────────────────────────────
4:36:19 PM: ​
4:36:19 PM: ❯ Version
4:36:19 PM:   @netlify/build 27.0.1
4:36:19 PM: ​
4:36:19 PM: ❯ Flags
4:36:19 PM:   baseRelDir: true
4:36:19 PM:   buildId: 62616bc1a81b45791685d48e
4:36:19 PM:   deployId: 62616bc1a81b45791685d490
4:36:19 PM: ​
4:36:19 PM: ❯ Current directory
4:36:19 PM:   /opt/build/repo
4:36:19 PM: ​
4:36:19 PM: ❯ Config file
4:36:19 PM:   No config file was defined: using default values.
4:36:19 PM: ​
4:36:19 PM: ❯ Context
4:36:19 PM:   production
4:36:19 PM: ​
4:36:19 PM: ────────────────────────────────────────────────────────────────
4:36:19 PM:   1. Build command from Netlify app                             
4:36:19 PM: ────────────────────────────────────────────────────────────────
4:36:19 PM: ​
4:36:19 PM: $ yarn build
4:36:19 PM: yarn run v1.22.10
4:36:19 PM: warning package.json: No license field
4:36:19 PM: $ svelte-kit build
4:36:19 PM: vite v2.9.5 building for production...
4:36:20 PM: transforming...
4:36:21 PM: ✓ 20 modules transformed.
4:36:21 PM: rendering chunks...
4:36:21 PM: .svelte-kit/output/client/_app/manifest.json                               1.17 KiB
4:36:21 PM: .svelte-kit/output/client/_app/pages/__layout.svelte-f21a9b1f.js           0.53 KiB / gzip: 0.35 KiB
4:36:21 PM: .svelte-kit/output/client/_app/error.svelte-e00f686d.js                    1.56 KiB / gzip: 0.75 KiB
4:36:21 PM: .svelte-kit/output/client/_app/pages/index.svelte-c5ad33f0.js              12.85 KiB / gzip: 4.44 KiB
4:36:21 PM: .svelte-kit/output/client/_app/start-e5c1b3b9.js                           22.97 KiB / gzip: 8.64 KiB
4:36:21 PM: .svelte-kit/output/client/_app/chunks/index-666e2032.js                    7.36 KiB / gzip: 3.00 KiB
4:36:21 PM: .svelte-kit/output/client/_app/assets/pages/__layout.svelte-5d285071.css   7.07 KiB / gzip: 2.40 KiB
4:36:21 PM: vite v2.9.5 building SSR bundle for production...
4:36:21 PM: transforming...
4:36:22 PM: ✓ 21 modules transformed.
4:36:22 PM: Generated an empty chunk: "hooks"
4:36:22 PM: rendering chunks...
4:36:22 PM: .svelte-kit/output/server/manifest.json                               1.45 KiB
4:36:22 PM: .svelte-kit/output/server/index.js                                    65.72 KiB
4:36:22 PM: .svelte-kit/output/server/entries/endpoints/api/mail/index.js         0.60 KiB
4:36:22 PM: .svelte-kit/output/server/entries/endpoints/api/contentful/index.js   0.53 KiB
4:36:22 PM: .svelte-kit/output/server/entries/pages/__layout.svelte.js            0.25 KiB
4:36:22 PM: .svelte-kit/output/server/entries/fallbacks/error.svelte.js           0.72 KiB
4:36:22 PM: .svelte-kit/output/server/entries/pages/index.svelte.js               6.10 KiB
4:36:22 PM: .svelte-kit/output/server/chunks/index-87d5ee21.js                    2.79 KiB
4:36:22 PM: .svelte-kit/output/server/chunks/hooks-1c45ba0b.js                    0.00 KiB
4:36:22 PM: Run npm run preview to preview your production build locally.
4:36:22 PM: 
4:36:22 PM: > Using @sveltejs/adapter-netlify
4:36:22 PM:   No netlify.toml found. Using default publish directory. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration for more details 
4:36:22 PM: > ENOENT: no such file or directory, open 'build/_redirects'
4:36:22 PM:     at Object.openSync (node:fs:585:3)
4:36:22 PM:     at Object.writeFileSync (node:fs:2157:35)
4:36:22 PM:     at appendFileSync (node:fs:2219:6)
4:36:22 PM:     at generate_lambda_functions (file:///opt/build/repo/node_modules/@sveltejs/adapter-netlify/index.js:237:2)
4:36:22 PM:     at adapt (file:///opt/build/repo/node_modules/@sveltejs/adapter-netlify/index.js:68:11)
4:36:22 PM:     at adapt (file:///opt/build/repo/node_modules/@sveltejs/kit/dist/chunks/index4.js:180:8)
4:36:22 PM:     at file:///opt/build/repo/node_modules/@sveltejs/kit/dist/cli.js:937:11
4:36:22 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
4:36:22 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4:36:22 PM: ​
4:36:22 PM: ────────────────────────────────────────────────────────────────
4:36:22 PM:   "build.command" failed                                        
4:36:22 PM: ────────────────────────────────────────────────────────────────
4:36:22 PM: ​
4:36:22 PM:   Error message
4:36:22 PM:   Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
4:36:22 PM: ​
4:36:22 PM:   Error location
4:36:22 PM:   In Build command from Netlify app:
4:36:22 PM:   yarn build
4:36:22 PM: ​
4:36:22 PM:   Resolved config
4:36:22 PM:   build:
4:36:22 PM:     command: yarn build
4:36:22 PM:     commandOrigin: ui
4:36:22 PM:     environment:
4:36:22 PM:       - VITE_SENDGRID_API
4:36:22 PM:     publish: /opt/build/repo/build
4:36:24 PM: Creating deploy upload records
4:36:22 PM:     publishOrigin: ui
4:36:22 PM:   functionsDirectory: /opt/build/repo/functions
4:36:23 PM: Caching artifacts
4:36:23 PM: Started saving node modules
4:36:23 PM: Finished saving node modules
4:36:23 PM: Started saving build plugins
4:36:24 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:36:23 PM: Finished saving build plugins
4:36:23 PM: Started saving pip cache
4:36:23 PM: Finished saving pip cache
4:36:23 PM: Started saving emacs cask dependencies
4:36:23 PM: Finished saving emacs cask dependencies
4:36:23 PM: Started saving maven dependencies
4:36:23 PM: Finished saving maven dependencies
4:36:23 PM: Started saving boot dependencies
4:36:23 PM: Finished saving boot dependencies
4:36:23 PM: Started saving rust rustup cache
4:36:23 PM: Finished saving rust rustup cache
4:36:23 PM: Started saving go dependencies
4:36:23 PM: Finished saving go dependencies
4:36:24 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:36:24 PM: Failing build: Failed to build site
4:36:24 PM: Finished processing build request in 19.637121954s

Hey @robindelaater

SvelteKit requires the _redirects file as it uses a rewrite to enable SSR. This is something handled by the adapter during build.`

It would appear the adapter isn’t trying to create the file (in this instance) instead trying to write to it, but as it doesn’t exist (I assume you haven’t created a _redirects file yourself) it is throwing an error.

If you create an empty _redirects file in the repository this may provide a workaround. As this adapter is maintained by SvelteJS, you may best create (and find more direct assistance via) an issue on GitHub.