Nodejs_compat in Page Functions
Howdy all,
I'm trying to deploy TinaCMS (https://github.com/tinacms/tinacms) self-hosted (https://tina.io/docs/reference/self-hosted/database-adapter/overview/) on Pages using Workers KV. |
I set up a
functions/graphql.ts
to handle a graphql endpoint that imports some nodejs specific libraries from Tina.
The deployments failed for it.
There was a hint given by the error messages to add nodejs_compat
as a compatiblity flag which I proceed to do in the Dashboard for both preview and prodution deployments but this did not seem to change when I retried the deployment.
Similarly wrangler pages dev ./out --compatibility-date 21-11-2023 --compatibility-flags nodejs_compat
does not seem to work end gives me the same error:
Any hints?3 Replies
nodejs_compat requires the imports to be prefixed with node:
https://developers.cloudflare.com/workers/runtime-apis/nodejs/
Aahhh didn't notice that in the docs. Ok, so i guess monkey patching or rewriting on my end 🙂 Thanks 🙂
I posted a Pull Request to add this information to the error message 😄 https://github.com/cloudflare/workers-sdk/pull/4485
GitHub
Add info about
node:${module}
syntax for nodejs_compat by zmilona...Fixes # [insert GH or internal issue number(s)].
What this PR solves / how to test:
This updates the error message to point the user that they might be missing node: in the module name for the impo...