ollama / ollama-js

Ollama JavaScript library
https://ollama.com
MIT License
2.03k stars 145 forks source link

ReferenceError: XMLHttpRequest is not defined #84

Closed liugezhou closed 3 months ago

liugezhou commented 4 months ago
image

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

ozgrozer commented 4 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.

skeetmtp commented 2 months ago

Note for people stuck to nodejs < 18

npm install xhr2
global.XMLHttpRequest = require('xhr2');
stephcurt commented 2 months ago

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).

cool-firer commented 2 months ago

is the supposed to be fixed? xhr2 global patch is not convenient