compatibility_flags = [ "nodejs_compat" ] not working

I get this message even after adding this flag to the wrangler.toml file
The package "http" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file to enable Node.js compatibility.
The package "http" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file to enable Node.js compatibility.
even when using different compatibility dates, currently with compatibility_date = "2023-08-15" I have also tried the legacy node_compat = true flag instead of the new compatibility_flags = [ "nodejs_compat" ] setting. Also tried running it with both and it gets mad. Also tried installing the packages manually and it keeps erroring out. Is there anything I'm doing wrong with this flag? How am I supposed to use it exactly? This is all caused by trying to include the googleapis package that has http2 (its the one thing that crashes with the legacy flag. With the new flag about 50 things show the "Add "node_compat = true" " flag
7 Replies
Migmac
Migmac9mo ago
I get this message when I try installing http2 and node-polyfill-webpack-plugin
service core:user:talk-eng-worker: Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
at core:user:talk-eng-worker:2363:13 in checkTypeSupport
at core:user:talk-eng-worker:2386:40 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:6953:7 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:7958:7 in node-modules-polyfills:https
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:8079:23 in node-modules-polyfills-commonjs:https
at core:user:talk-eng-worker:20:52 in __require2
at core:user:talk-eng-worker:9932:21 in node_modules/gaxios/build/src/gaxios.js
service core:user:talk-eng-worker: Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
at core:user:talk-eng-worker:2363:13 in checkTypeSupport
at core:user:talk-eng-worker:2386:40 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:6953:7 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:7958:7 in node-modules-polyfills:https
at core:user:talk-eng-worker:17:58 in __init
at core:user:talk-eng-worker:8079:23 in node-modules-polyfills-commonjs:https
at core:user:talk-eng-worker:20:52 in __require2
at core:user:talk-eng-worker:9932:21 in node_modules/gaxios/build/src/gaxios.js
Some pointers would be useful, thanks! =]
Hello, I’m Allie!
IIRC, neither node_ nor nodejs_compat have support for XMLHttpRequest
Migmac
Migmac9mo ago
Is there a flag I could add?
Hello, I’m Allie!
No, I think it is one of the APIs that you have to write your way around
Migmac
Migmac9mo ago
RIP, its a googleapis import
Hello, I’m Allie!
No, I mean that can either find an alternative to googleapis that uses Fetch, or write it yourself
Migmac
Migmac9mo ago
This is useful! Thank you