bluebird
bluebird copied to clipboard
Guard against falsey process.versions to support React Native
I ran into this issue when working on a React Native project. When I imported bluebird, it would throw Cannot read property 'node' of undefined
and I had to work around the problem by using Object.defineProperty(process, 'versions', ...)
to get bluebird to work.
Strangely, this "bug" only became a problem after using bluebird in the project for a month or so. I haven't hunted down the culprit but it is populating global.process
with an [object process]
I'm not sure if this is really the correct change, since this logic effects whether setImmediate/process.nextTick is used, and we probably want to use setImmediate in a React Native environment.
I would suggest changing isNode
, not isRecentNode
.
This is blocking debugging with VSCode. @L8D how was your workaround looking like?
And why changing isNode
? I mean it is actually node running. But this introduces an compatibility issue with vscode.
I am getting the same error while using bluebird with react native. RN: 0.57.5 Bluebird: 3.5.3
Is there anything I can do?
I have fixed it temporarily like this
- Install node modules
- Open
bluebird.js
- Modify the code for
ret.isRecentNode
to
ret.isRecentNode = ret.isNode && (function() {
var version = process.version.split(".").map(Number);
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
})();