在终端错误中启动Node / express项目

时间:2014-11-19 12:10:50

标签: node.js express mean-stack

昨晚我正在研究MEAN堆栈教程https://thinkster.io/angulartutorial/mean-stack-tutorial/,一切正常。然后今天早上当我再次尝试启动时,我不断收到npm错误。它说无法连接到localhost:27017,但我昨晚连接到端口:3000,/ bin / www代码设置为3000。

我认为错误可能在package.json文件中:“start”:“node ./bin/www”但我不确定并需要帮助。感谢。

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

> flapper-news@0.0.0 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! flapper-news@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the flapper-news@0.0.0 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

这是日志文件:

    0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
2 info using npm@1.4.28
3 info using node@v0.10.32
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart flapper-news@0.0.0
6 info start flapper-news@0.0.0
7 verbose unsafe-perm in lifecycle true
8 info flapper-news@0.0.0 Failed to exec start script
9 error flapper-news@0.0.0 start: `node ./bin/www`
9 error Exit status 8
10 error Failed at the flapper-news@0.0.0 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 ]

2 个答案:

答案 0 :(得分:1)

27017是mongodb的默认端口。确保在运行应用程序之前启动了mongodb服务器。

答案 1 :(得分:0)

尝试跑步:

 killall -9 node

检查它是否有效:

ps aux