2017-03-09 81 views
1

我試圖使用Mongoose與typescript 2.2.1,express 4.15.2和節點v7.7.2,但是當我嘗試連接到MongoDB它引發此錯誤:貓鼬:「TypeError:」監聽器「參數必須是一個函數」連接

TypeError: "listener" argument must be a function 
at Socket.once (events.js:307:11) 
at Socket.connect (net.js:943:10) 
at Socket.connect (/home/fabian/Projects/Huis-Pils/node_modules/async-listener/index.js:76:27) 
at Object.exports.connect.exports.createConnection (net.js:76:35) 
at Connection.connect (/home/fabian/Projects/Huis-Pils/node_modules/mongodb-core/lib/connection/connection.js:399:11) 
at Pool.connect (/home/fabian/Projects/Huis-Pils/node_modules/mongodb-core/lib/connection/pool.js:638:16) 
at Server.connect (/home/fabian/Projects/Huis-Pils/node_modules/mongodb-core/lib/topologies/server.js:384:17) 
at Server.connect (/home/fabian/Projects/Huis-Pils/node_modules/mongodb/lib/server.js:361:17) 
at open (/home/fabian/Projects/Huis-Pils/node_modules/mongodb/lib/db.js:226:19) 
at Db.open (/home/fabian/Projects/Huis-Pils/node_modules/mongodb/lib/db.js:249:44) 
at NativeConnection.doOpen (/home/fabian/Projects/Huis-Pils/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:58:11) 
at NativeConnection.Connection._open (/home/fabian/Projects/Huis-Pils/node_modules/mongoose/lib/connection.js:531:15) 
at /home/fabian/Projects/Huis-Pils/node_modules/mongoose/lib/connection.js:289:11 
at new wrappedPromise (/home/fabian/Projects/Huis-Pils/node_modules/async-listener/index.js:372:16) 
at NativeConnection.Connection.open (/home/fabian/Projects/Huis-Pils/node_modules/mongoose/lib/connection.js:288:17) 
at Mongoose.connect (/home/fabian/Projects/Huis-Pils/node_modules/mongoose/lib/index.js:242:47) 

代碼:

import * as mongoose from "mongoose"; 
(<any>mongoose).Promise = global.Promise; 
mongoose.connect('mongodb://localhost/test'); 

我只是想不通我做錯了什麼。

回答

2

我有類似的問題,也可以是節點7.7.2

如果隨後的錯誤,它應該由https://github.com/nodejs/node/pull/11762

+1

是的,我相信是這樣,我下載節點v6.10.0得到解決,我沒有問題那裏。好找! – Fablock

相關問題