Configuration file for Pages projects does not support "node_compat"
I'm having some compatability issues, where my code works on Workers but not on Pages Functions.
54 Replies
Hey. Pages doesn't support
node_compat
, but it does support nodejs_compat
, which is slightly different@Vero 🐙 will this help? https://x.com/jasnell/status/1795872787594358875
or it is only for Workers (not Pages Functions)
James M Snell (@jasnell) on X
A @Cloudflare Workers Node.js compatibility update... we will soon be enabling a revised version of the nodejs_compat flag (called nodejs_compat_v2) that makes a couple of key improvements to the implementation...
Twitter
functions are workers
so it's available for them too
but if it will help depends on your needs and what packages you require
knex
is the package. and if they were the same thing, or functioned in the same way then node_compat
flag would work the same as nodejs_compat
but they do not.Being the same doesn't mean the support is the same (long story)
Product explicitly decided to not support node_compat due to it being our not recommended thing
so then what is the solution? where this library works on Workers but not on Pages?
@Walshy | Deploying
https://github.com/jjjrmy/hono-sutando-cf-worker-pages
https://sutando-cf.dventures.workers.dev/users
https://sutando-cf.pages.dev/users
Pages Failed Deployment:
0c8ad5d4-69f0-46d3-98fe-81e3922b1bc3
GitHub
GitHub - jjjrmy/hono-sutando-cf-worker-pages
Contribute to jjjrmy/hono-sutando-cf-worker-pages development by creating an account on GitHub.
?
was just responding with a reproduciton repo - so maybe someone on the Workers/Pages team can get to the bottom of it
Again, not supporting node_compat was an explicit decision, it was not done intentionally. It isn't a bug.
so then what do you do in a case like this? just not use Cloudflare?
Find an alternative library that does support edge runtimes.
if everything points to using Cloudflare Pages over Workers, but Pages doesn't support the same libraries
read the deploy log - it seems like it's a different limitation than the library itself
Error: Failed to publish your Function. Got error: Uncaught Error: Dynamic require of "events" is not supported
you or a library is doing a dynamic require('events'). This isn't supported by esbuild (the Workers/Pages bundler that Wrangler uses).
then how is it working on Workers?