klei / generator-klei

A Yeoman generator for generating awesome module or app boilerplates! MEAN-stack (all parts optional) with Grunt and Bower sweetness..
MIT License
38 stars 4 forks source link

Can't run `grunt serve` after scaffolding #11

Open seriema opened 10 years ago

seriema commented 10 years ago

I created a new project with yo klei and chose not to have Stylesheets, but I accepted the Todo app. Directly after I run grunt serve which gives me this:

$ grunt serve
Running "serve" task

Running "clean:temp" (clean) task
Cleaning .tmp...OK

Running "html2js:app" (html2js) task
Successfully converted 1 html templates to js.

Running "jshint:app" (jshint) task

✔ No problems

Running "injector:app" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (8 files)
>> Nothing changed

Running "copy:index" (copy) task
Copied 1 files

Running "express:dev" (express) task
Starting background Express server
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
CONTROLLER-ACTION:ADD POST /api/todo
CONTROLLER-ACTION:ADD GET /api/todo/:id
CONTROLLER-ACTION:ADD PUT /api/todo/:id

Running "watch" task
Waiting...CONTROLLER-ACTION:ADD DELETE /api/todo/:id
CONTROLLER-ACTION:ADD GET /api/todo
DEVELOPMENT Server listening on port 1337

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (/Users/john-philipjohansson/Documents/GitHub/whatthee5/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:546:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (/Users/john-philipjohansson/Documents/GitHub/whatthee5/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (/Users/john-philipjohansson/Documents/GitHub/whatthee5/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:415:13)
seriema commented 10 years ago

Hmm I needed to start mongod first. Would be nice with a message or a task that starts it, instead of this random error.

joakimbeng commented 10 years ago

It is stated in the readme that it's required to run MongoDB before running grunt serve.

But you're right, this could be clarified by wrapping the mongoose.connect call with a try-catchstatement.

duyongguang commented 10 years ago

I run the same code, in linux,It is OK, but in windows return the errors , when I run server

Error: failed to connect to [182.192.145.121:27017] at null. (D:\workspace\xxx\node_modules\mongoose\node_mod ules\mongodb\lib\mongodb\connection\server.js:546:74) at EventEmitter.emit (events.js:106:17) at null. (D:\workspace\xxx\node_modules\mongoose\node_mod ules\mongodb\lib\mongodb\connection\connection_pool.js:150:15) at EventEmitter.emit (events.js:98:17) at Socket. (D:\workspace\xxx\node_modules\mongoose\node_m odules\mongodb\lib\mongodb\connection\connection.js:533:10) at Socket.EventEmitter.emit (events.js:95:17) at net.js:441:14 at process._tickCallback (node.js:415:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16)

joakimbeng commented 10 years ago

And you are sure that there is a mongodb instance running on 182.192.145.121:27017?