Spruche icon indicating copy to clipboard operation
Spruche copied to clipboard

SyntaxError: Unexpected token

Open muhx opened this issue 9 years ago • 2 comments

I am new in express. When i run npm start it sends me a message like this can you help me why?

/Users/Data/spruche/routes/index.js:22
router.get('/start', async (req, res) => {
                           ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/Data/spruche/app.js:15:16)
    at Module._compile (module.js:571:32)

npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.4.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the spruche package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs spruche
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls spruche
npm ERR! There is likely additional logging output above.

muhx avatar Apr 03 '17 09:04 muhx

I'm sorry, this is my mistake.The Version 7.4.0 does't support the direct use async, please add --harmony:

node --harmony ./bin/www

You can modifypackage.json:

"scripts": {
    "start": "node --harmony ./bin/www ",
    "dev": "nodemon --harmony ./bin/www"
  },

Or update Node to v7.7.0.

IceEnd avatar Apr 03 '17 11:04 IceEnd

Thanks @IceEnd , it helps so much..

muhx avatar Apr 03 '17 12:04 muhx