N
Nuxt4w ago
Serbemas

Issue creating new nuxt 3 project: Cannot require() ES Module in a cycle

Hi everyone. When I try to create a new nuxt 3 project, using node v22.12.0 and pnpm 9.15.2 I get an error related with ES Module and unplugin-vue-router. Has anyone faced this error before? If use npm it works fine
No description
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Serbemas. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I can offer some insights into your issue with creating a new Nuxt 3 project using pnpm. While there isn't a direct mention of the specific error you're encountering, there are some related issues and potential solutions that might help: 1. ES Module compatibility issues are common when working with Nuxt 3, as it uses native ES modules. The error you're seeing about not being able to require() an ES Module in a cycle suggests there might be a circular dependency problem or an incompatibility with how the modules are being loaded. 2. The fact that it works with npm but not with pnpm suggests there might be an issue with how pnpm is resolving dependencies or handling ES modules. To troubleshoot this issue, you could try the following: 1. Check for any CJS (CommonJS) require statements in your project and replace them with ESM imports. As mentioned in this GitHub issue comment (https://github.com/nuxt/nuxt/issues/29943#issuecomment-1853056724), replacing CJS require imports with ESM imports has helped resolve similar issues for some users. 2. Make sure your package.json has the correct configuration for ES modules. You should have "type": "module" in your package.json file. 3. Try using a slightly older version of Node.js. While you're using v22.12.0, which is very recent, some users have reported better compatibility with LTS versions like v18 or v20. 4. If the issue persists, you might want to try creating a minimal reproduction of the problem and sharing it on the Nuxt GitHub issues (https://github.com/nuxt/nuxt/issues) page. The Nuxt team and community can provide more specific help if they can reproduce the issue. 5. As a temporary workaround, you could use npm to create the project and then switch to pnpm for further development, if you prefer using pnpm. If none of these suggestions help, it would be beneficial to share more details about the exact error message and perhaps parts of your configuration files (like nuxt.config.js) to get more targeted assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@590598161400201236> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?