Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using co with node 0.10.x? #247

Open
angelochen960 opened this issue Oct 10, 2015 · 3 comments
Open

using co with node 0.10.x? #247

angelochen960 opened this issue Oct 10, 2015 · 3 comments

Comments

@angelochen960
Copy link

Hi,

co's home page says:

When using node 0.10.x and lower or browsers without generator support, you must use gnode and/or regenerator.

but when gnode an app, got:

ReferenceError: Promise is not defined
    at co (.../node_modules/co/index.js:50:14)

is there a way to polyfill this with Bluebird? or what is the version of co that can be used with node 0.10.x?

Thanks,
A.C.

@madbence
Copy link
Contributor

co@4+ requires a Promise implementation. For versions of node < 0.11 and for many older browsers, you should/must include your own Promise polyfill.

So yeah, you should do global.Promise = require('bluebird') or similar.

@joshbeam
Copy link

Yes you can override global.Promise. Also, check out this current PR for "bring your own promise" in this repo. Kind of interesting (and related) #244

@floatdrop
Copy link

@madbence @joshbeam yeah, this will work for most of the cases, but we using co in test framework ava and including global polyfill will affect code under testing (if code relies on Promise object, but don't polyfill it in test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants