2016-10-12 61 views
0

我正在關注流星網站教程(https://www.meteor.com/tutorials/blaze/collections)。流星錯誤 - 將任務存儲在集合中

但是當你添加一行:

出口const的任務=新Mongo.Collection( '任務');

我得到以下錯誤:

/Users/user/.meteor/packages/meteor-tool/.1.4.1_2.fpzmec++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313 
 
\t \t \t \t \t \t throw(ex); 
 
\t \t \t \t \t \t^
 
MongoError: failed to connect to server [localhost:27017] on first connect 
 
    at Object.Future.wait (/Users/user/.meteor/packages/meteor-tool/.1.4.1_2.fpzmec++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15) 
 
    at new MongoConnection (packages/mongo/mongo_driver.js:216:27) 
 
    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16) 
 
    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10) 
 
    at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1) 
 
    at new Mongo.Collection (packages/mongo/collection.js:103:40) 
 
    at meteorInstall.imports.api.tasks.js (imports/api/tasks.js:4:14) 
 
    at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1) 
 
    at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1) 
 
    at Module.Mp.import (/Users/user/.meteor/packages/modules/.0.7.6_1.j54juu++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16) 
 
    - - - - - 
 
    at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:313:35) 
 
    at emitOne (events.js:77:13) 
 
    at [object Object].emit (events.js:169:7) 
 
    at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:260:12) 
 
    at [object Object].g (events.js:260:16) 
 
    at emitTwo (events.js:87:13) 
 
    at [object Object].emit (events.js:172:7) 
 
    at Socket.<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/connection.js:162:49) 
 
    at Socket.g (events.js:260:16) 
 
    at emitOne (events.js:77:13) 
 
Exited with code: 1 
 
Your application is crashing. Waiting for file change.

+0

您正在使用哪個端口?我可以看到27017 – hlx

回答

0

本教程中的行:

export const Tasks = new Mongo.Collection('tasks'); 

是從線不同:

Export Tasks const = new Mongo.Collection ('tasks'); 

代碼的目標是初始化一個新常量,Tasks,將其設置爲新的Mongo.Collection,然後將其導出。

+0

謝謝傑里米。已經糾正,但不是問題。 – Will

+0

是否在文件中導入了Mongo? –

+0

是的,從'meteor/mongo'導入{Mongo}; – Will