Cloudflare DevelopersCD
Cloudflare Developers3y ago
16 replies
MrDiamond

globalThis.XMLHttpRequest is not a constructor

I am trying to use wrangler deploy to deploy my app, but it keeps giving this error. I am not using XMLHttpRequest afaik.

Dependencies:
"devDependencies": {
    "@types/express": "^4.17.20",
    "@types/node": "^20.8.7",
    "nodemon": "^3.0.1",
    "tsx": "^3.14.0",
    "typescript": "^5.2.2",
    "wrangler": "^3.14.0"
},
"dependencies": {
    "canvas": "^2.11.2",
    "define-data-property": "^1.1.1",
    "discord-interactions": "^3.4.0",
    "dotenv": "^16.3.1",
    "express": "^4.18.2"
}

wrangler.toml
name = "discord-bot"
main = "./dist/index.js"
compatibility_date = "2023-10-21"
node_compat = true

Full error
  Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
    at worker.js:31375:13 in checkTypeSupport
    at worker.js:31397:40 in
  node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
    at worker.js:15:58 in __init
    at worker.js:31662:7 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
    at worker.js:15:58 in __init
    at worker.js:31880:7 in node-modules-polyfills:http
    at worker.js:15:58 in __init
    at worker.js:32000:23 in node-modules-polyfills-commonjs:http
    at worker.js:18:52 in __require2
    at worker.js:32019:18 in node_modules/methods/index.js
   [code: 10021]
Was this page helpful?