Closed liugezhou closed 3 months ago
I had the same error on Node.js v17
.
Tried lots of things then accidently found out that it's working perfect with Node.js v18
.
Note for people stuck to nodejs < 18
npm install xhr2
global.XMLHttpRequest = require('xhr2');
Note for people stuck to nodejs < 18
npm install xhr2
global.XMLHttpRequest = require('xhr2');
This worked for me, although as soon as I fixed it I realized I'd set that dockerfile to node14 for some reason (smh).
is the supposed to be fixed? xhr2 global patch is not convenient
When i run node demo.js,and then:
/User/xxx/Demo/aidemo/node_modules/whatwg-fetch/dist/fetch.umd.js:540 var xhr = new XMLHttpRequest(); ^
ReferenceError: XMLHttpRequest is not defined