Typescript and Node - ReferenceError: XMLHttpRequest is not defined

I was able to successfully call getEntries using a single plain javascript file for both the browser and node. However, using Typescript it works in the browser, but fails with the node execution:
“ReferenceError: XMLHttpRequest is not defined”
I am using esbuild to bundle the Typescript into Javascript and then pointing my node file to the compiled Javascript. Maybe the esbuild compilation is forcing Contentful to think it’s in a browser?

Thanks for any help!