nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 227 forks source link

globalThis is not defined. #537

Closed argahsuknesib closed 5 months ago

argahsuknesib commented 5 months ago

I get this error,


/users/kbisenug/decentralized-stream-aggregator/node_modules/readable-stream/lib/ours/util.js:5
const AbortSignal = globalThis.AbortSignal || require('abort-controller').AbortSignal
                    ^

ReferenceError: globalThis is not defined
    at Object.<anonymous> (/users/kbisenug/decentralized-stream-aggregator/node_modules/readable-stream/lib/ours/util.js:5:21)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/users/kbisenug/decentralized-stream-aggregator/node_modules/readable-stream/lib/stream.js:31:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

How should I avoid this?

benjamingr commented 5 months ago

globalThis is defined in Node.js 12+ which is the earliest version of Node.js readable-stream 4 supports.

If you need to support an older version of Node.js use readable-stream at version 3 which runs Node 6+