KoaJs and the SyntaxError Unexpected identifier error - or that time when I understood generators
April 11, 2014
It was quite sometime since I wrote a blog post with an error message in the title. However I have now got this error so many times, and keep scratching my head every time. Also I think I can explain why it happens.
Here’s an example on how to make this error occur, from the co-monk library README (not anymore maybe):
Running that code (either with “node –harmony koaErrorFail.js” or test it with “mocha –harmony-generators koaErrorFail.js”) fail with the error from the title of the blog post:
yield users.remove({}); ^^^^^ SyntaxError: Unexpected identifier At this point you start to think that you forgot to run the example with the --harmony flag. But of course you do that, right? Ah, maybe you are running the wrong version of Node. Again, no....
