It builds on my machine and dies on deploy

This is the most common wall people hit after exporting from an AI builder. The editor had a dev server, your host does not. Five causes cover almost every case. Check them in this order — the first two are about eighty percent of what I see.

1. Environment variables exist locally, not on the host

Your .env file never leaves your machine. The host has its own copy, and it needs one for every environment.

How to checkOpen your host's project settings and compare the variable list against your .env line by line. Check that each one is enabled for Production AND Preview, not just Production.
What to changeAdd every missing variable, then redeploy. A redeploy is required: variables are baked in at build time, and saving them does not rebuild anything on its own.

In Next.js, browser code only sees variables whose names start with NEXT_PUBLIC_; in Vite, VITE_. Those values are copied into the public bundle at build time, so anyone can read them. Add the prefix only to values that are safe to publish — a site URL, a publishable or anon key — and change every place that reads them. A secret never gets the prefix: move the code that uses it to the server (cause 3).

2. The import works on Windows and fails on Linux

Your computer does not care about letter case in file names. The build server does. A file imported as ./Card that is really named ./card.tsx builds at home and fails in the cloud.

How to checkRead the error: it usually says Module not found with the exact path. Compare that path character by character against the real file name.
What to changeRename the file or the import so they match exactly, including the first letter. Git sometimes hides a rename that only changes case — use git mv to force it.

The same applies to folders, and to imports that resolve through an index file.

3. Server code is being called from the browser

AI builders happily write a database call or a secret-key call inside a component. It works while everything runs on one machine and breaks the moment the browser is the one executing it.

How to checkSearch your source for process.env without the public prefix, and for imports of server-only packages inside component files.
What to changeMove that code into an API route or a server action and call it from the component. The secret must never reach the browser bundle.

If a secret key was ever shipped in browser code, rotate it. Anyone who opened your site has it.

4. A package is installed locally but missing from package.json

Something got installed by hand during a debugging session and never written into the manifest. Your machine still has it; a clean install does not.

How to checkKeep the lockfile. Run npm ci — it removes node_modules and installs exactly what package.json and the lockfile list — then build. If it fails the same way, this is your cause.
What to changeInstall the package properly so it is written to package.json, commit the lockfile, and redeploy. If your build tool sits in devDependencies, check how the host installs: npm skips devDependencies when NODE_ENV is production or with --omit=dev. In that case move the tool to dependencies or change the install command.

A lockfile that is out of date with package.json fails the build outright on most hosts.

5. The build command or output directory is wrong

The export assumes one framework preset; the host guessed another. The build passes and the host serves an empty directory, or the build never runs at all.

How to checkCompare the build command and output directory in the host settings against the scripts in package.json.
What to changeSet them explicitly. For Vite the output is dist, for Next.js it is managed by the framework preset, for a static export it is out. Also pin the Node version if the host defaults to a newer one than you used.

A build that succeeds with zero files in the output looks identical to a broken deploy. Check the file count in the build log.

Not one of these five?

Send me the link and the exact error text. I will tell you what is broken and what it would take to fix, in writing, within 24 hours. That part is free, and you are not obliged to hire me afterwards.

If you do want it fixed: emergency rescue starts at $600, and I name one fixed number before I start.

Send me the link