SvelteKit "Cannot find adapter" / "No adapter specified" - Fix Build
SvelteKit needs an adapter to turn the built app into something a host can run. The build fails (or adapter-auto errors) when no adapter is installed, the configured adapter package is missing, or adapter-auto cannot detect the CI/host environment.
What this error means
A SvelteKit build fails with Cannot find module '@sveltejs/adapter-...', No adapter specified, or an adapter-auto message that it could not detect the deployment target in CI. It happens during the post-vite build adapt phase.
> Using @sveltejs/adapter-auto
Error: Could not detect a supported production environment. See
https://svelte.dev/docs/kit/adapters to learn how to configure your app
to run on the platform of your choice.Diagnose it: is it resolution, transform, or memory?
Bundler failures in CI fall into three families and the error text often points at the wrong one. A module that resolves on your machine and not on the runner is nearly always case sensitivity or a missing optional dependency; a transform error is a config or version mismatch; and an unexplained kill with no stack is the out-of-memory reaper, not a build error at all.
# 1. resolution: does the file exist with EXACTLY that case?
git ls-files | grep -i "the/imported/path"
# 2. transform: what versions is CI actually resolving?
npm ls webpack vite rollup esbuild typescript 2>/dev/null | head -20
# 3. memory: was it killed rather than failed?
# exit 137 = SIGKILL (OOM). Nothing in the bundler log will explain it.
node --max-old-space-size=4096 node_modules/.bin/vite buildCommon causes
adapter-auto cannot detect the environment
adapter-auto only recognizes a fixed set of hosts. In generic CI or a custom host it cannot pick an adapter, so the adapt step fails.
Adapter not installed or wrong for the target
The svelte.config.js references an adapter package that is not in node_modules, or uses adapter-static for a site that needs SSR (or vice versa).
How to fix it
Install and pin an explicit adapter
Replace adapter-auto with the adapter for your actual target and install it.
npm install -D @sveltejs/adapter-node
// svelte.config.js
import adapter from '@sveltejs/adapter-node'
export default { kit: { adapter: adapter() } }Match the adapter to the route requirements
- If you have server routes/endpoints, use a server adapter (node, vercel, cloudflare).
- For a fully static site, use
adapter-staticand ensure all routes are prerenderable. - Install the adapter as a dev dependency so a clean
npm cibuild can find it.
Make the build reproducible before you debug it
- Pin the Node major in
setup-nodeand inengines. A bundler that resolves native bindings will pick a different prebuilt binary across majors. - Delete
node_moduleslocally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state. - Set
CI=truelocally to reproduce. Several toolchains change behaviour under it, including treating warnings as errors. - Exit code 137 is an out-of-memory kill. Raise
--max-old-space-sizeor move to a larger runner rather than searching the bundler config.
How to prevent it
- Pin an explicit adapter rather than relying on
adapter-autoin CI. - Declare the adapter in
devDependencies. - Match the adapter (static vs server) to your routes' rendering needs.