events.js:163
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (D:\projects\myblog\node_modules\mongodb-core\lib\topologies\server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:191:7)
at Connection.<anonymous> (D:\projects\myblog\node_modules\mongodb-core\lib\connection\pool.js:274:12)
at Object.onceWrapper (events.js:293:19)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:194:7)
at Socket.<anonymous> (D:\projects\myblog\node_modules\mongodb-core\lib\connection\connection.js:177:49)
估计您已经找到原因了。
因为MongoDB没有启动。在Windows操作系统启动MongoDB吧!
供参考。
Love MongoDB! Have fun!