Error when using deployed version of Nuxt module with Sanity depdendencies
I am currently trying to use Sanity dependencies within a Nuxt module. The module works completely fine in the playground, but when deploying to npm, it breaks in my Nuxt 3 App. The server starts up and then throws "Cannot find module './cjs/react.development.js'" once a client connects to the app.
I installed the module in the Nuxt app like this:
4 Replies
Hi @Justix. 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 don't have enough specific information to directly address your issue with the Sanity dependencies and the "Cannot find module './cjs/react.development.js'" error in your Nuxt 3 app. However, I can provide some general insights and suggestions based on similar issues reported in Nuxt 3:
1. Version compatibility: The error you're experiencing might be related to version incompatibilities. In one of the reported issues, updating the Vue version resolved a similar problem. You could try updating your Vue version:
Github Issue (closed): The new version release is missing files and cannot be run directly. (https://github.com/nuxt/nuxt/issues/30022)
2. ESM compatibility: Nuxt 3 uses native ES modules, which can sometimes cause issues with dependencies that are not fully ESM-compatible. You might need to check if the Sanity dependencies you're using are fully compatible with ESM.
Docs > Guide > Concepts > ES Modules (https://nuxt.com/docs/guide/concepts/esm)
3. Build configuration: Ensure that your build configuration is correct. You might need to add the problematic module to the
build.transpile
array in your nuxt.config.ts
:
Docs > Guide > Concepts > ES Modules > Troubleshooting ESM Issues (https://nuxt.com/docs/guide/concepts/esm#troubleshooting-esm-issues)
4. Dependency resolution: Sometimes, issues can arise due to how dependencies are resolved. You might want to try clearing your dependency cache and reinstalling:
Docs > Guide > Directory-structure > node_modules (https://nuxt.com/docs/guide/directory-structure/node_modules)
If these suggestions don't resolve your issue, you might need to create a minimal reproduction of the problem and seek further assistance from the Nuxt community or the maintainers of the Sanity-related packages you're using.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@388689607488700418> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@danielroe do you have any idea why this could happen? your module (
@nuxtjs/sanity
) works fine with the same dependenciesthere are some deeply problematic dependencies in the sanity stack. we set optimizeDeps in the module - you can take a look at the code and replicate in your own module