Capacitor and Nuxt - Running 'npx cap add android' errors due to an index.html is not generated by nuxt build

I have a Nuxt 2 app. I’ve followed the docs to add Capacitor and Android Support.

Everything is fine up to the point of running npx cap add android. The android folder is generated however there are errors in the terminal

√ Adding native android project in android in 342.51ms
√ Syncing Gradle in 944.40μp
√ add in 345.44ms
× copy android - failed!
[error] The web assets directory (.\.nuxt) must contain an index.html file.
        It will be the entry point for the web portion of the Capacitor app.
√ Updating Android plugins in 33.68ms
× update android - failed!
[error] Error: ENOENT: no such file or directory, open

I’m not running Nuxt in static mode (due to routes and content pulled in dynamically from a CMS). So I run nuxt build which generates the output into a folder named .nuxt by default.

However nuxt build doesn’t create an index.html as an entry point, the nuxt build actually states Entrypoint app = server.js Hence the error above where it can’t find index.html in the .nuxt directory.

Does anyone know a way to resolve this?

I’ve found resources when using nuxt generate for a static app but not nuxt build for a spa like in my case.

having an index.html is a Capacitor’s requirement, so if you don’t have an index.html Capacitor won’t work for you