lift.js exits with "ReferenceError: Promise is not defined" after update.
Senci opened this issue · 2 comments
Hi Guys, I've seen that there has been changes lately so I decided to update. Unfortunately node is now exiting with following error message:
> node spawn.js ~/Documents/phridge «22:16»
/Users/sli/node_modules/phridge/lib/lift.js:14
return new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at /Users/sli/node_modules/phridge/lib/lift.js:14:20
at Object.spawn (/Users/sli/node_modules/phridge/lib/spawn.js:45:12)
at Object.<anonymous> (/Users/sli/Documents/phridge/spawn.js:3:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
After it didn't work, I figured a fresh install may fix the issue. Unfortunately it didn't. I've un- and reinstalled node through brew, un- and reinstalled all npm packages. So I should have a fresh install, but unfortunately the Error is still present.
content of "spawn.js":
var phridge = require('phridge'); // https://www.npmjs.com/package/phridge
phridge.spawn().then(function(phantom) {
phantom.run(function(resolve) {
this.page = webpage.create();
});
});
Cheers!
Hi, thanks for the feedback and your PR.
This is somewhat intentional. I've waited for this change for the next breaking change because I expected that this would break someone's code. However, Promise
should be globally available since node@0.12
. If you're running phridge with an older node version, you just need to add a Promise
polyfill to global
and everything should be working fine.
Oh okay, I see. You are right, although brew build node 0.12, it was unable to successfully link and therefore I was still on an old version for some reason. After some permission changes and a new install I linked node 0.12 and now it works like a charm.