Open staminna opened 6 years ago
I am also getting the same error. Which Node.js version you are using? Author mention in his article that "Another important point — We won’t be using callbacks, We even won’t be using traditional Promises. We are going to use the great async-await feature introduced in NodeJS 7.6."
So i think this may be the problem with Node.js version. I have Node.js 6.10.0 on my machine.
I am using Node.js v8.0
@redkarsanket Yes you're right, It won't work on NodeJS versions prior to 7.6 .
@staminna Have you followed all these steps ?
Run npm install
to install all the dependencies.
Run npm install -g nodemon
to install Nodemon Globally.
Run npm start
to run the NodeJS Server.
It should be working fine after this.
Are you sure you're using the correct NodeJS version ?
The error unexpected token function
<- Means that NodeJS can't recognize the token async function
there, Which usually happens because the NodeJS version doesn't support async-await. Please run a node --version
to see which version you're using.
If it's still showing 8.0, You can try reinstalling the latest NodeJS.
Installing at least node 8.1.4 worked for me @redkarsanket, though now there is another issue. Will open new one.
Hi. i using node v8.12.0 and when run npm install command i get bellow error
added 216 packages from 120 contributors and audited 374 packages in 10.655s found 19 vulnerabilities (12 low, 2 moderate, 5 high) run
npm audit fixto fix them, or
npm auditfor details
I cloned the repo and ran npm install.
[nodemon] starting
node ./bin/www` /webapp/todo-api/controllers/todos.controller.js:6 exports.getTodos = async function(req, res, next){ ^^^^^^^^SyntaxError: Unexpected token function at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/Users/jorge/webapp/json_api_assets/todo-api/routes/api/todos.route.js:5:22)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
[nodemon] app crashed - waiting for file changes before starting...`