Darragh Kenny
Darragh Kenny

Reputation: 31

Starting Node/express project in terminal error

I was working on a MEAN stack tutorial last night, https://thinkster.io/angulartutorial/mean-stack-tutorial/ , and everything was working fine. Then this morning when I try to start it again I keep getting an npm error. It says cannot connect to localhost: 27017, but I was connected to port:3000 last night, and the /bin/www code is set to 3000.

I think the error is maybe in the package.json file: "start": "node ./bin/www" but I am not sure and need help. Thanks.

Darraghs-MacBook-Pro:flapper-news dkdesign$ npm start

> [email protected] start /Users/dkdesign/flapper-news
> node ./bin/www


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (/Users/dkdesign/flapper-news/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:549:74)
    at emit (events.js:106:17)
    at null.<anonymous> (/Users/dkdesign/flapper-news/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
    at emit (events.js:98:17)
    at Socket.<anonymous> (/Users/dkdesign/flapper-news/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
    at Socket.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:419:13)

npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the flapper-news 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 their info via:
npm ERR!     npm owner ls flapper-news
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/dkdesign/flapper-news
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/dkdesign/flapper-news/npm-debug.log
npm ERR! not ok code 0

And this is the log files:

    0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart [email protected]
6 info start [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec start script
9 error [email protected] start: `node ./bin/www`
9 error Exit status 8
10 error Failed at the [email protected] start script.
10 error This is most likely a problem with the flapper-news package,
10 error not with npm itself.
10 error Tell the author that this fails on your system:
10 error     node ./bin/www
10 error You can get their info via:
10 error     npm owner ls flapper-news
10 error There is likely additional logging output above.
11 error System Darwin 14.0.0
12 error command "node" "/usr/local/bin/npm" "start"
13 error cwd /Users/dkdesign/flapper-news
14 error node -v v0.10.32
15 error npm -v 1.4.28
16 error code ELIFECYCLE
17 verbose exit [ 1, true ]

Upvotes: 1

Views: 576

Answers (2)

MartianE
MartianE

Reputation: 404

Try running:

 killall -9 node

To check if it worked:

ps aux

Upvotes: 0

Dheeraj Kumar Aggarwal
Dheeraj Kumar Aggarwal

Reputation: 642

27017 is the mongodb's default port. Make sure, you have started the mongodb server before running your application.

Upvotes: 1

Related Questions