-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
"for await" loop throws Syntax Error: Unexpected reserved word #21617
Comments
You can only use for-await-of loop inside an async function. |
Node.js wrapper function that contains your module is not an async function (nor is it a generator). Identifier If you want to use (async () => {
try{
for await (let pkg of installPackages(items))
console.log(pkg);
}catch(e){
console.log(e.stack);
}
})(); If you're not sure whether something is a bug or not, I suggest posting in nodejs/help repo firstly next time. |
@trvsapjiac something like this is one indentation level less, has less lines and is more readable: async function main() {
for await (let pkg of installPackages(items))
console.log(pkg);
}
main().catch(e => console.error(e.stack)); Also, it has the wrapper function name in the stacktrace. |
This does not look like it's an issue in Node.js. Also, I believe this question is answered. I am going to close this. Side notes:
|
Thank You - Next time I will try the nodejs/help repo first. |
bumped up with this using zmq + node v8.17 - switching to a newer version resolved this issue. |
thanks |
Try this:
|
This Code does not recognize "await" with Async Iterator and throws:
I was really excited about async generators and installed Node 10.5 but I can't get a thing to work? I tried the --harmony-async-iterator flag but that returns: unsupported flag?
The text was updated successfully, but these errors were encountered: