What you see
You exported your app from Lovable, Bolt or Cursor to GitHub, connected the repo to Netlify or Vercel, and the very first deploy fails at the end of the log.
On Netlify:
Configuration error
Error message
Deploy did not succeed: Deploy directory 'dist' does not exist
Resolved config
build:
command: yarn build
publish: /opt/build/repo/dist
On Vercel:
Error: No Output Directory named "dist" found after the Build completed. You can configure the Output Directory in your Project Settings.
The folder name in quotes changes (dist, build, public), but the meaning is the same.
Why it happens
A static deploy has two steps: run the build command, then upload one folder, the publish directory (Netlify) or Output Directory (Vercel). Netlify’s docs are blunt about it: “Only files in the publish directory are deployed.”
The error means step two looked for a folder that step one never created. In the Netlify forum thread for this exact error, the build ran Rollup and wrote build/main.js, while the publish directory was set to dist. In another thread it was the reverse: Vite wrote dist/ and Netlify was told to deploy build.
The usual causes:
- Wrong folder name. Netlify’s framework docs list
distas the publish directory for Vite-based tools such as Astro, andbuildfor Create React App. Lovable and Bolt export Vite apps, so their output isdist. - Wrong framework preset on Vercel. Vercel sets the Output Directory for you when it detects a framework. With the “Other” preset it serves
publicif that folder exists, otherwise the project root. - The app lives in a subfolder. If
package.jsonis infrontend/, the build runs at the repo root and fails or writes somewhere else. Netlify’s publish directory is relative to the base directory. - The build never really built. An empty build command, or a
buildscript that only type-checks, leaves no folder. Scroll up in the log first: if the build itself failed, the missing folder is only a symptom.
Fix it, from zero
1. Find out what your build really writes
Netlify’s troubleshooting page starts here: “first make sure it builds locally in your own development environment.”
npm install
npm run build
ls # look for dist/ (Vite) or build/ (Create React App)
That folder name is the ground truth. Don’t change the host until you know it.
2. Netlify: set build command and publish directory
Open Project configuration > Developer settings > Continuous deployment > Build settings and set:
- Base directory: empty, or the subfolder that holds
package.json(e.g.frontend) - Build command:
npm run build - Publish directory:
dist(or whatever step 1 showed)
Or commit a netlify.toml at the repository root. Netlify’s docs say “the configuration file settings override build settings specified in the UI”:
[build]
command = "npm run build"
publish = "dist"
3. Vercel: pick the right preset, then leave the folder alone
In Settings > Build and Deployment > Framework Settings, choose the framework you actually use (Vite for a Lovable or Bolt export). If you use a preset, leave Output Directory on its default. Turn on the override only if your build writes somewhere custom. If the app is in a subfolder, set Root Directory to it.
Also check the repo for a vercel.json with an outputDirectory key. Vercel’s docs say it overrides the Output Directory for that deployment, so a stale value from a tutorial or an AI edit will keep failing until you fix or remove it.
4. Add environment variables before the first deploy
This is where a “successful” first deploy still ships a broken app. Vite replaces import.meta.env.VITE_* values “statically at build time”. If VITE_SUPABASE_URL isn’t set on the host when the build runs, the deployed JavaScript contains undefined.
- Add every
VITE_variable from your local.envin the host dashboard before you deploy. - Netlify: “Environment variable changes require a build and deploy to take effect.”
- Vercel: changes “are not applied to previous deployments, they only apply to new deployments.” Redeploy after adding them.
- Never put a secret in a
VITE_variable. Vite’s docs warn they “should not contain sensitive information such as API keys” because they end up in the bundle. More on this in environment variables undefined in production.
5. Add the SPA rewrite now, not after the first bug report
Once the folder is found, the next thing a Vite single-page app hits is a 404 when someone refreshes /dashboard. Fix it in the same commit:
- Netlify: create
public/_redirectswith/* /index.html 200 - Vercel: add a
vercel.jsonrewrite from/(.*)to/index.html
The full explanation is in 404 on refresh (404: NOT_FOUND / Page not found).
Check it worked
- The deploy log ends with the site published, not a configuration error.
- Open the live URL, then open a deep route like
/dashboardin a new tab and refresh it. It should load. - Open the browser console and look for
undefinedAPI URLs or failed requests tolocalhost.
Or run the free production-readiness checker on your live URL: it tests the deep-link refresh, looks for secret keys in your JavaScript and spots leftover localhost addresses in about 20 seconds. If you want someone to go through the whole launch path for you, there’s a written pre-launch audit.