Error: Line 2: Unexpected reserved word

Posted on
  • Hi. My code was working, but I've just upgraded to v1.99 on my Espruino WiFi, and now I'm getting the above error.

    My code starts like this:

    const neopixel = require("neopixel");
    const Lights = require("Lights");
    

    It definitely seems to be something to do with that second line, as I can load in other modules, but if I move the lines of code around the error message still stays Error: Line 2.

    Of course, I can rename my module if I need to. Seems like something weird is happening though. Any idea what?

    Thanks.

    ERROR: [notify_error] Error: Line 2: Unexpected reserved word
    ERROR: Error: Line 2: Unexpected reserved word     at createError (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:87438:21)     at unexpectedTokenError (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:87507:13)     at throwUnexpectedToken (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:87512:15)     at parsePrimaryExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:87870:17)     at parseLeftHandSideExpressionAllowCall (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:87961:61)     at parsePostfixExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:88009:16)     at parseUnaryExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:88065:20)     at parseBinaryExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:88154:16)     at parseConditionalExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:88213:16)     at parseAssignmentExpression (chrome-extension://bleoifhkdalbjfbobjac­kfdifdneehpo/main.js:88317:16)
    
  • Please post all of your code.

    Where are you seeing the error message?

    The message appears to be coming from chrome - not from espruino

  • It's possible the error you're hitting is because you've turned minification on and are using some ES6 features like arrow functions?

    But as @Wilberforce says we'd need the full code - or at the very least some code that shows the error. Those two lines by themselves seem fine.

  • The error occurs when I click the button to send to Espruino in the IDE. I get a red popup message over the left-hand pane.

    I'm using the Chrome extension in this instance, if it makes a difference.

    @Gordon I don't think I'm using any fancy new features, but I'll check that.

  • Oh, I guess it might mean line 2 of the module. I didn't think of that...

  • Ahh, that's a point! Neither did I :) I guess Lights is your own custom module?

  • Yeah. The module defines a class. Is that the problem? I thought support for classes was added a couple of versions ago?

    Ahh. "Module minification" was switched to "Esprima". I've changed it to "No minification" and it works now.

    It would have been nice if the error message included a bit more information. eg Saying that it was line 2 of the module file. Is that possible?

    Thanks.

  • The module defines a class. Is that the problem?

    It shouldn't be at all - unfortunately the minifier its showing its age now. It might be time to ditch Esprima completely and move to the closure compiler (there's an open PR on GitHub that adds an offline version of closure - it's just quite a bit of code to include!).

    It would have been nice if the error message included a bit more information

    Just done - next IDE update should have it in :)

  • Thanks! :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Error: Line 2: Unexpected reserved word

Posted by Avatar for user91203 @user91203

Actions