✘ [ERROR] The `nodejs_compat` compatibility flag cannot be used in conjunction with the legacy `--node-compat` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the `--node-compat` argument from your CLI command or `node_compat = true` from your config file.
So I removed the second one but now I get:
service core:user:rsstojson: Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
I saw something similar with an earlier test I did. I got the impression that most npm modules should “mostly” just work, but I’m not seeing that. What am I doing wrong?
The newer nodejs_compat flag requires prefixed imports ('node:foo' rather than just 'foo'), not only in your code but in any modules you import. If the modules are still using unprefixed imports for built-in Node modules, they won’t work until they are update to use the prefix.
Prefixed imports have been the “right” way to do it in Node for a while, and Node seems to be moving toward prefix-only, but yeah, a module that hasn’t been updated for it won’t work with nodejs_compat.
The older node_compat, which is polyfills, may work for you if you run into this. I don’t think it’s being updated any more, but if it works, it works.