Difference between `node_compat = true` and `compatibility_flags = [ "nodejs_compat" ]`?

The docs say that we should add compatibility_flags = [ "nodejs_compat" ] to wrangler.toml in order to use node modules. But the errors I get when running wrangler tell me to add node_compat = true instead. Only the latter seems to work. What's the difference? Is the former deprecated and the docs out of date?
3 Replies
nickchomey
nickchomeyOP12mo ago
Erisa
Erisa12mo ago
node_compat = true is the old method, compatibility_flags = [ "nodejs_compat" ] is the new method. There are some differences in supported features between the two. If adding the new compat flag worked for you, then it sounds like wranglers warning is wrong
nickchomey
nickchomeyOP12mo ago
Thanks. As it turns out, it looks like you need to add node: for the required modules with compatibility_flags, but (perhaps) not with node_compat. The errors mostly go away then. Still, all sorts of other issues are popping up once the initial requires have been resolved (or bypassed). It seems like it would be a large job to get this library (NATS.js) working in CF Workers. I'll explore other options
Want results from more Discord servers?
Add your server