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

npm test fails with token const error. Any idea on how in can resolve it? #320

Closed
visualjeff opened this issue Feb 17, 2017 · 6 comments
Closed
Labels

Comments

@visualjeff
Copy link

Node: 6.9.1
Hapi: ^16.0.1
Lab: ^11.2.1

Its been driving me nuts... Anybody else run into this?

jeffg@debian:~/Documents/nodeHapiTemplate$ npm test

> nodeHapiTemplate@1.0.0 test /home/jeffg/Documents/nodeHapiTemplate
> ./node_modules/lab/bin/lab -c

/home/jeffg/Documents/nodeHapiTemplate/node_modules/espree/espree.js:443
        throw err;
        ^

SyntaxError: Unexpected token const
    at Parser.instance.raise.instance.raiseRecoverable (/home/jeffg/Documents/nodeHapiTemplate/node_modules/espree/espree.js:439:19)
    at Parser.instance.unexpected (/home/jeffg/Documents/nodeHapiTemplate/node_modules/espree/espree.js:472:14)
    at Parser.pp$2.parseBindingAtom (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:1535:10)
    at Parser.pp$1.parseVarId (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:1094:18)
    at Parser.pp$1.parseVar (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:1077:12)
    at Parser.pp$1.parseVarStatement (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:962:8)
    at Parser.pp$1.parseStatement (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:741:17)
    at Parser.pp$1.parseTopLevel (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:658:23)
    at Parser.parseTopLevel (/home/jeffg/Documents/nodeHapiTemplate/node_modules/espree/espree.js:301:34)
    at Parser.parse (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:528:15)
    at Object.parse (/home/jeffg/Documents/nodeHapiTemplate/node_modules/acorn/dist/acorn.js:3357:37)
    at Object.parse (/home/jeffg/Documents/nodeHapiTemplate/node_modules/espree/espree.js:738:21)

Any tips or pointers would be appreciated. Its just showed up after I blew away my node_modules directory and performed a fresh npm install.

Thanks,

Jeff

@platinumazure
Copy link
Member

@visualjeff Hard to tell, but it looks like you're running npm test for a different project, not espree?

If that's the case, then you need to find where espree is being used in your project. When you call espree.parse, you should pass in an ecmaVersion option with a value of 6 or greater. That will hopefully fix your issue.

@visualjeff
Copy link
Author

Yes, I'm building a hapi server. I will grep the project and then the node modules to attempt to find where espree is being used. I'll share my findings. Thank you for the hint.

@visualjeff
Copy link
Author

Its lab 11.2.2 that is using espree.

node_modules/lab/lib/coverage.js:36

I'm going to attempt to bring up the version of lab and test again.

@platinumazure
Copy link
Member

@visualjeff So either the lab module does not support coverage for ES6 syntax, or the lab module will have configuration you can tweak to ensure it calls espree with ES6+ configuration.

In either case, this is likely not an espree issue, so I'm going to close the issue. Please reopen if you believe there's still an espree issue after your investigation. Thanks!

@visualjeff
Copy link
Author

Think I found out what is causing the issue.

hapijs/lab#668

@visualjeff
Copy link
Author

Resolved.

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

No branches or pull requests

3 participants