Question

Exported Bolt project fails on Netlify, but runs fine inside Bolt

Solved · 356 viewsasked by coop_builds

Downloaded my project as zip, pushed to GitHub, connected Netlify. Build log:

But in Bolt the app runs and I never saw any of these.

What I’ve tried

Set NODE_VERSION=20 on Netlify because a blog said so. Didn't change anything.

Comment
Does npm run build pass when you run it in Bolt's terminal? rafa_dev
same errors there. never ran it before honestly coop_builds

3 answers

Marked as helpful by the asker
rafa_dev

Bolt's preview runs the dev server, which strips types without checking them. Netlify runs the build script, which starts with tsc -b and fails on any type error. So these errors were always there, you just never ran the build.

Order of work:

  1. Run npm run build locally (or in Bolt's terminal) so you see the same list.
  2. TS6133 (unused imports): harmless, delete the imports. Or set "noUnusedLocals": false in tsconfig.app.json if there are many.
  3. TS2345 and friends: real bugs, fix them. api.ts:88 passing a number where a string is expected will bite you at runtime.

Don't "fix" it by changing the build script to only vite build. It works, but you're shipping the bugs.

Comment
Fixed all 25. Two of them were actual bugs in the admin page, so thanks for the warning coop_builds
The dev vs build difference explained a lot for me too thiago_n
katja_s

Make the build part of your routine: run npm run build before every push, or add a small GitHub Action that runs it on each pull request. Then Netlify is never the first to tell you.

Comment
added the action, it already caught one thing coop_builds
priscila_m

Also check your env vars on Netlify. Bolt's .env isn't in the zip, so after the build passes you'll get a blank site if VITE_ variables aren't set in Netlify's settings.

Comment