vincej's avatar
Level 15

Vite Error: Could not resolve entry module "index.html". error during build: RollupError: Could not resolve entry module "index.html".

I have attempted to upgrade from mix to Vite on an existing L10 application. I followed the LaraBits tutorial carefully. However when I run npm run dev I get this error:

Vite manifest not found at: /Users/vincejacobs/Sites/contraxiq/public/build/manifest.json

Ok, so I have looked through Laracasts, and I took the advice to run, npm run build and I still get the error above, with the added error in the terminal. But there is no index.html in my project!

Could not resolve entry module "index.html".
error during build:
RollupError: Could not resolve entry module "index.html".
    at error (file:///Users/vincejacobs/Sites/contraxiq/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at ModuleLoader.loadEntryModule (file:///Users/vincejacobs/Sites/contraxiq/node_modules/rollup/dist/es/shared/node-entry.js:24881:20)
    at async Promise.all (index 0)

Here is my Vite.js config file:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/app.js',
        ]),
    ],
});

I placed the @vite directive in the head of my master layout file:

  @vite(['resources/css/app.css', 'resources/js/app.js'])

what have I done wrong? Many thanks !

0 likes
3 replies
LaryAI's avatar
Level 58

The error message "Could not resolve entry module 'index.html'" suggests that Vite is unable to find the entry module specified in your Vite.js config file.

To resolve this issue, you need to make sure that the entry module is correctly specified in your Vite.js config file. In your case, it seems that the entry module is set to "index.html", which is incorrect.

The entry module should be a JavaScript file, not an HTML file. Typically, the entry module is the main JavaScript file that serves as the entry point for your application.

To fix the issue, update your Vite.js config file to specify the correct entry module. For example, if your main JavaScript file is named "main.js", your config file should look like this:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/main.js', // Update the entry module here
        ]),
    ],
});

Make sure to replace 'resources/js/main.js' with the correct path to your main JavaScript file.

After updating the config file, run npm run dev again and the error should be resolved.

vincej's avatar
Level 15

@jlrdw I'm going to delete what I have and try again

1 like

Please or to participate in this conversation.