N
Nuxt2mo ago
Heisnberg

@nuxtjs/apollo not working with nuxt4

I had a nuxt 3 project that use @nuxtjs/apollo package to handle GraphQL queries and mutation after I migrated to nuxt 4 using ncu -u I am getting this error:
warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

$ nuxt prepare

ERROR Cannot read properties of undefined (reading 'build') 1:52:32 PM

at module.exports (node_modules/@nuxtjs/apollo/lib/module.js:7:39)
at callModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:784:208)
at installModules (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:660:11)
at async initNuxt (node_modules/nuxt/dist/index.mjs:5383:3)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:5585:5)
at async loadNuxt (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:982:16)
at async Object.run (node_modules/@nuxt/cli/dist/chunks/prepare.mjs:32:18)
at async runCommand (node_modules/citty/dist/index.mjs:316:16)
at async runCommand (node_modules/citty/dist/index.mjs:307:11)
at async runMain (node_modules/citty/dist/index.mjs:445:7)
warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

warn: incorrect peer dependency "graphql@16.11.0"

$ nuxt prepare

ERROR Cannot read properties of undefined (reading 'build') 1:52:32 PM

at module.exports (node_modules/@nuxtjs/apollo/lib/module.js:7:39)
at callModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:784:208)
at installModules (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:660:11)
at async initNuxt (node_modules/nuxt/dist/index.mjs:5383:3)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:5585:5)
at async loadNuxt (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:982:16)
at async Object.run (node_modules/@nuxt/cli/dist/chunks/prepare.mjs:32:18)
at async runCommand (node_modules/citty/dist/index.mjs:316:16)
at async runCommand (node_modules/citty/dist/index.mjs:307:11)
at async runMain (node_modules/citty/dist/index.mjs:445:7)
I tried removing and installing @nuxtjs/apollo package but I am still getting this error in the installation process
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @Heisnberg. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're encountering with @nuxtjs/apollo after migrating to Nuxt 4 is likely due to module compatibility issues. Nuxt 4 requires all modules to be compatible with its new build-time-only module system. Many Nuxt 3 modules, especially those not updated for Nuxt 4, may break because they rely on APIs or hooks that no longer exist or have changed in Nuxt 4. Specifically, the error:
Cannot read properties of undefined (reading 'build')
Cannot read properties of undefined (reading 'build')
suggests that the @nuxtjs/apollo module is trying to access a property or hook (build) that is no longer available in Nuxt 4. This is a common issue when using modules that have not been updated for Nuxt 4's new module system. According to the Nuxt 4 migration guide, you should: - Move all your buildModules into modules. - Check for Nuxt 3 (and by extension, Nuxt 4) compatibility of modules. - If a module is not compatible, you may need to wait for an update or look for alternatives that support Nuxt 4 [Migration: Configuration > Modules]. There is no indication in the provided knowledge sources that @nuxtjs/apollo is currently compatible with Nuxt 4. The error you see is typical for modules that have not been migrated. The recommended approach is: 1. Check if there is a Nuxt 4 compatible version of @nuxtjs/apollo or an official migration path. 2. If not, you may need to wait for an update or consider using Apollo Client directly in your Nuxt app without the module wrapper, or look for community-maintained alternatives. Summary:
The knowledge sources do not provide a direct solution for using @nuxtjs/apollo with Nuxt 4. The error is due to module incompatibility, and you should check for updates or alternatives. If you need Apollo functionality immediately, consider integrating Apollo Client manually until a compatible module is released [Migration: Configuration > Modules]. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@754394587833040957> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?