madhums / node-express-mongoose-demo

A simple demo app using node and mongodb for beginners (with docker)
https://nodejs-express-demo.fly.dev
MIT License
5.12k stars 1.38k forks source link

Issue with ES6 on 'npm start' #200

Closed iamwhitebox closed 8 years ago

iamwhitebox commented 8 years ago

It seems that there is a transpilation error in the controllers while running npm start, here is a snapshot of the error:

/Users/jeffreyjones/Sites/node-express-mongoose-demo/app/controllers/users.js:8 const { wrap: async } = require('co'); ^

SyntaxError: Unexpected token { 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/jeffreyjones/Sites/node-express-mongoose-demo/config/routes.js:7:15) at Module._compile (module.js:409:26) 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/jeffreyjones/Sites/node-express-mongoose-demo/server.js:40:1) at Module._compile (module.js:409:26) 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 Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:968:3 [nodemon] app crashed - waiting for file changes before starting...

nick-ChenZe commented 8 years ago

check your node version.It should be NodeJs >= 6.x

madhums commented 8 years ago

@nick-ChenZe that's right. @iamwhitebox make sure to have node >= 6.x. That will solve the issue you are facing.

piyushmakhija commented 7 years ago

@madhums Can you share some resource which explain what "const { wrap: async } = require('co');" statement is doing. I checked this https://github.com/tj/co repo but couldn't understand how it works. Also, can you share some more resources which let us understand the use of async, function pointers, etc in multiple controllers.