Weird Prerender Error with rolldown-vite
Im currently facing one weird error, where i tried to build the project with
rolldown-vite
, it throws some variables not defined (eg: Cannot read properties of undefined (reading 'defineStore')
or Cannot access 'm' before initialization
)
not sure what happened, i tried cleanup build and it still faced with same issue
update: I revert back to standard vite and now everything is fine
what i've identified is rolldown-vite
somehow would not build according the dependency sequence, and compiled in undetermined sequence
unfortunately it only happens when my file count exceeds certain number, adding additional file would start to cause build behaves weirdly2 Replies
Hi @LeFt_HitD. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources do not contain specific information about the "rolldown-vite" build tool or the exact errors you're encountering (such as
Cannot read properties of undefined (reading 'defineStore')
or Cannot access 'm' before initialization
) in the context of Nuxt prerendering or building.
However, based on related issues in the sources, such errors often occur when dependencies are not properly initialized, imported, or registered. For example, with Pinia or Vuex stores, you must ensure the store is correctly set up and imported in your components, and that the relevant modules are included in your Nuxt configuration. If a function like defineStore
is undefined, it usually means Pinia is not properly installed or registered in your project, or the import path is incorrect. Similarly, issues with undefined variables can sometimes be caused by build tool misconfigurations or using outdated/unsupported versions of dependencies, as seen in other Nuxt-related errors in the sources.
If you are using a non-standard build tool like "rolldown-vite" (which is not mentioned in the official Nuxt documentation), compatibility issues may arise. The official Nuxt build process relies on Vite or Webpack, and deviations from this may not be supported or documented.
If you can, try building your project with the standard Nuxt build commands (npx nuxt build
or npx nuxt generate
) to see if the issue persists. If the error only occurs with "rolldown-vite," it may be a compatibility issue outside the scope of official Nuxt support.
If you need further help, please provide more details about your setup, or consider using the standard Nuxt build process as described in the documentation for more predictable results Nuxt build command, Prerendering in Nuxt.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@189715647293423616> Kapa.ai is still learning and improving, please let me know how I did by reacting below.