Capacitor does not find index.html for a Vue app inside Laravel
Capacitor cannot find index.html in webDirShort answer
Capacitor copies the folder named in webDir, and that folder must hold the final index.html. A Laravel project serves its HTML through Blade, so its Vite build writes assets and a manifest, not an index.html. Build the Vue app as a standalone Vite project, or point webDir at a folder that really contains index.html.
Fix it fast
1Find out which cause you have
Print your webDir and list that folder. If index.html is not in the list, one of the causes below applies.
grep -n "webDir" capacitor.config.* ls dist2Match what you see, then jump to its fix
- 1
The folder named in webDir is missing, or you did not run the build before syncing.webDir points to a folder that does not exist or is emptyFix - 2
The Laravel build output holds a manifest and hashed assets, and no index.html; the page is a Blade view.The Vue app is built by Laravel's Vite plugin, which produces no index.htmlFix - 3
The app tries to load a URL, not the copied files.A live-reload server URL is set in the Capacitor configFix
- 1
What does the error look like?
Capacitor cannot find index.html in webDirthe web app files are not found by Capacitor after npx cap sync
Cause 1 of 3
webDir points to a folder that does not exist or is empty
1Check
webDir is the directory of your compiled web assets and it should contain the final index.html. Vite writes to dist unless build.outDir says otherwise.
grep -n "webDir" capacitor.config.*
grep -n "outDir" vite.config.*2Fix
Make webDir equal to the real build output folder, then build and sync in that order.
// capacitor.config.ts
const config = { appId: 'com.example.app', appName: 'App', webDir: 'dist' };
export default config;
# then
npm run build
npx cap sync3Verify
index.html is in the folder and sync completes.
ls dist/index.html && npx cap syncConfirmed by capacitorjs.com
Cause 2 of 3
The Vue app is built by Laravel's Vite plugin, which produces no index.html
1Check
In Laravel the HTML comes from a Blade template with the Vite directive, and the plugin writes a manifest and a build directory (buildDirectory option). The build is meant for the Laravel server.
grep -n "buildDirectory\|laravel(" vite.config.*2Fix
Create a standalone Vue project (or a second Vite config) with its own index.html that calls your Laravel API, and give Capacitor that project's build folder as webDir.
// vite.config.js of the standalone Vue app
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({ plugins: [vue()], build: { outDir: 'dist' } });3Verify
After npm run build, dist/index.html exists.
npm run build && ls dist/index.htmlConfirmed by laravel.com
Cause 3 of 3
A live-reload server URL is set in the Capacitor config
1Check
server.url loads an external URL in the web view. It is intended for live-reload servers and not for production.
grep -n "url\|cleartext" capacitor.config.*2Fix
Remove server.url from the config you build releases with.
// capacitor.config.ts: delete the server block
// server: { url: 'http://192.168.1.10:5173', cleartext: true }3Verify
Run npx cap sync and open the app with the built files.
npx cap syncConfirmed by capacitorjs.com
How do I stop it coming back?
- Keep the mobile web app in its own folder with its own package.json and index.html.
- Run the build and cap sync together in one script.
- Keep server.url only in a dev config file.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
appium driver install uiautomator2 fails or the driver will not start
Error installing uiautomator2 driver
Run appium driver install uiautomator2 with the Appium server stopped, on a Node.js and npm version Appium supports (Node ^20.19, ^22.12 or 24+, npm 10+).
3 causes, each with a fixMobile apps
Appium returns 'The requested resource could not be found' (404)
http://localhost:4723/wd/hub
The client is calling a URL the server does not serve.
2 causes, each with a fixMobile apps
Expo cannot start the Android emulator: spawn adb ENOENT
spawn adb ENOENT
ENOENT means the tool that launched adb could not find an executable named adb on your PATH.
3 causes, each with a fixMobile apps
npm install --global expo-cli fails, or the legacy expo-cli will not run on new Node.js
The legacy expo-cli does not support Node +17
The global expo-cli is the legacy tool: its repository is archived and read-only.
2 causes, each with a fixMobile apps
Expo says it is unable to find expo in this project
Unable to find expo in this project - have you run yarn / npm install yet?
The Expo CLI ships inside the expo package, so the project must have expo as a dependency and installed in its own node_modules.
3 causes, each with a fixMobile apps
FCM rejects the message with INVALID_ARGUMENT
HTTP 400 from fcm.googleapis.com/v1/projects/PROJECT_ID/messages:send
INVALID_ARGUMENT is HTTP 400: FCM did not accept the request parameters.
3 causes, each with a fix