当我尝试在项目中运行sails lift时出现以下错误:
clayton@cfs846631:~/Documents/stream-sync$ sails lift
[Error: failed to connect to [localhost:27017]]
/home/clayton/Documents/stream-sync/node_modules/sails-mongo/lib/adapter.js:77
connection.createCollection(collectionName, function __DEFINE__(err, r
^
TypeError: Cannot call method 'createCollection' of undefined
at __DEFINE__ (/home/clayton/Documents/stream-sync/node_modules/sails mongo/lib/adapter.js:77:20)
at afterwards (/home/clayton/Documents/stream-sync/node_modules/sails-mongo/lib/adapter.js:469:7)
at /home/clayton/Documents/stream-sync/node_modules/sails-mongo/lib/adapter.js:465:7
at /home/clayton/Documents/stream-sync/node_modules/sails-mongo/lib/adapter.js:500:23
at /home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/db.js:273:18
at /home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/db.js:351:18
at Server.close (/home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/connection/server.js:210:38)
at Db.close (/home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/db.js:347:21)
at /home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/db.js:271:21
at null.<anonymous> (/home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/connection/server.js:563:7)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/home/clayton/Documents/stream-sync/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickDomainCallback (node.js:459:13)
我试图重新安装sails,并且还发现它可能与config中的adapters.js文件有关。我更新了mongo适配器以使用host:'localhost'。这个项目在我的笔记本电脑上工作正常,我只是想在我的桌面上设置它,所以我假设它与设置风帆或缺少节点模块的方式有关。
我不知道还有什么可以尝试。
答案 0 :(得分:1)
您收到此错误,因为sails无法连接到您的mongodb服务器。
[Error: failed to connect to [localhost:27017]]
安装/启动mongodb和风帆将正确提升。如果您无法运行mongodb,请尝试官方文档http://docs.mongodb.org/manual/installation/