Build before deploy
Your host will not run your dev server. It will usually install packages, run a build command, then serve the generated output.
The one idea: if it fails on your laptop with the production build, it will likely fail on the host too.
Dev is forgiving
npm run dev is for coding. It can hide issues that only appear when the app is bundled for production.
Common surprises are wrong import casing, unused broken code, missing assets, TypeScript errors, and environment variables used during build.
Find your build command
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Package scripts
For a Vite React app, your scripts may look like this. The build creates the production files. The preview command lets you test them locally.
{
"scripts": {
"dev": "vite --host 0.0.0.0",
"build": "vite build",
"preview": "vite preview --host 0.0.0.0"
}
}Test it locally
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
npm run build
npm run previewDo not deploy junk
Do not commit generated build folders unless your framework specifically requires it for your setup. For most React, Vue, Next, and Vite apps, the host builds from source.
Do not ignore build warnings blindly. A warning about a missing dependency or browser issue may become a broken page after deploy.
Ask AI carefully
Paste your build error into ChatGPT, Gemini, or Claude and ask for the smallest fix. Also paste your package.json if the error is about scripts or dependencies.
Check the answer before applying it. Make sure it does not remove important code, downgrade random packages, or add secrets into files.
Prompt:
My npm run build fails for this Vite React app. Give the smallest safe fix.
Here is the terminal error:
[paste error]
Here is package.json:
[paste package.json]Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done