Closed DidoMarchet closed 1 year ago
Please have a look at nuxt/nuxt#21768, it's basically the same issue. The problem will be fixed in nitro soon, in the meantime you can patch the graphql package for a successful deployment. The graphql
module tries to access globalThis.process
, which makes the deployment fail. Therefore, if you remove the respective code in the graphql
module that causes the issue via a patch, e.g. via pnpm, you have a workaround till the root cause is fixed:
pnpm patch graphql
code <generated_folder>
In node_modules/graphql/jsutils/instanceOf.mjs
remove the code that tries to access process
.
export const instanceOf = function instanceOf(value, constructor) {
return value instanceof constructor
}
Then apply the patch.
pnpm patch-commit <generated_folder>
The resulting patch should appear in package.json
to be applied during deployment.
"pnpm": {
"patchedDependencies": {
"graphql@16.7.1": "patches/graphql@16.7.1.patch"
}
}
Thanks! Kind regards,
Davide
Hi @Aietes, sorry if I reopen the thread but how ca deploy on Netlify? Because I don't know if it's possible to patch the modules on Netlify.
The issue occurs with the netlify-edge
preset. If I use netlify-builder
present it works ad expected.
Thanks and kind regards,
Davide
Hi @DidoMarchet , if you patch the library as described above, the pnpm patch functionality takes care of everything automatically. I hope I described the steps well, but there is also a patch documentation with a video.
Patching via this process actually creates a patch
folder in your repository, which contains the diff
(change) to the library. This change is referenced in your package.json
. When you deploy to Netlify, both the patch and the package.json
are uploaded to Netflify's server and built on that server. During the build, the changes are applied to the library on the server, exactly like they are applied to your local system. This allows you to fix issues in libraries immediately, so you don't need to wait till the issue is actually patched in a future release of that library.
I'm not using Netlify, but I used this workaround to deploy to Cloudflare pages, which is a very similar edge deployment.
Perfect, thanks again!
Environment
Describe the bug
Hi guys! I'm trying to deply in netlify with presets netlify-edge and netlify-builder. It works. But if I add the module @nuxtjs/apollo it return me this error:
Expected behaviour
No errors
Reproduction
Install and configure Nuxt Apollo and use it as below:
Additional context
No response
Logs
No response