laravel/framework · error · ViteException

Unable to locate file in Vite manifest: {$file}.

Error message

Unable to locate file in Vite manifest: {$file}.

What it means

Vite::chunk() throws ViteException when the requested entry point or asset key does not exist in the parsed manifest (build/manifest.json or the configured hot/build directory). The manifest is produced by vite build; a missing key means the entry name passed to @vite() / Vite::asset() does not correspond to anything Vite emitted.

Source

Thrown at src/Illuminate/Foundation/Vite.php:1042

            }
        }

        return $imports;
    }

    /**
     * Get the chunk for the given entry point / asset.
     *
     * @param  array  $manifest
     * @param  string  $file
     * @return array
     *
     * @throws \Illuminate\Foundation\ViteException
     */
    protected function chunk($manifest, $file)
    {
        if (! isset($manifest[$file])) {
            throw new ViteException("Unable to locate file in Vite manifest: {$file}.");
        }

        return $manifest[$file];
    }

    /**
     * Get the nonce attribute for the prefetch script tags.
     *
     * @return \Illuminate\Support\HtmlString
     */
    protected function nonceAttribute()
    {
        if ($this->cspNonce() === null) {
            return new HtmlString('');
        }

        return new HtmlString(' nonce="'.$this->cspNonce().'"');
    }

View on GitHub (pinned to e0f6eb3518)

Solutions

  1. Run npm run build (or npm run dev) so the manifest reflects the current entry points.
  2. Confirm the exact key by opening public/build/manifest.json and matching the string passed to @vite() byte-for-byte.
  3. Verify the build directory: config('app.asset_url') and the 'build' arg to Vite match where the manifest is emitted.
  4. On deploy, ensure the build step runs before code is live and that public/build is in the artifact.

Example fix

// before
@vite(['resources/js/app.jsx'])
// but manifest only has 'resources/js/app.tsx'

// after
@vite(['resources/js/app.tsx'])
Defensive patterns

Strategy: validation

Validate before calling

$manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
$entry = 'resources/js/app.tsx';
if (! isset($manifest[$entry])) {
    throw new RuntimeException("Entry {$entry} missing from manifest; rebuild assets.");
}
@vite([$entry]);

Type guard

function entryExistsInManifest(string $entry, ?array $manifest = null): bool {
    $manifest ??= json_decode(file_get_contents(public_path('build/manifest.json')), true) ?: [];
    return isset($manifest[$entry]);
}

Try / catch

use Illuminate\Foundation\ViteException;

try {
    Vite::asset('resources/js/app.tsx');
} catch (ViteException $e) {
    // log and fall back to unbuilt source or abort build
}

Prevention

When it happens

Trigger: Calling Vite::asset('resources/js/missing.js') or @vite(['resources/js/missing.js']) where the path string is not exactly a key in public/build/manifest.json. Also when the manifest is stale because a new build was not run, or the build directory config does not match where the manifest actually lives.

Common situations: Renamed or deleted an input file but did not rerun npm run build. Path casing or extension mismatch ('.js' vs '.ts' vs '.jsx'). Wrong VITE_BUILD_DIR / build_directory config for a multi-build setup. Deployed code without the compiled assets. Running dev (npm run dev) but VITE is not detecting the hot file.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/687d9e30ddac2039. Report an issue: GitHub.