"退出代码8"流星应用示例

时间:2014-11-22 16:30:23

标签: javascript linux mongodb meteor

我是Meteor.js的新手,目前正致力于"leaderboard"示例应用。插入一行代码后:

Template.leaderboard.player = function(){
  return "Some other text"
}

我在应用界面中收到错误:

“你的应用程序正在崩溃。这是最新的日志。”

Hello world

/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:173
                        throw(ex);
                              ^
ReferenceError: Template is not defined
    at app/leaderboard.js:13:1
    at app/leaderboard.js:17:3
    at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:168:10
    at Array.forEach (native)
    at Function._.each._.forEach (/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
    at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change."

我重新保存了文件,进入终端并停止了服务器并重新启动它并收到了:

=> Exited with code: 8
I20141122-11:01:32.695(-5)? Hello world       
W20141122-11:01:32.697(-5)? (STDERR) 
W20141122-11:01:32.699(-5)? (STDERR) /home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:173
W20141122-11:01:32.701(-5)? (STDERR)                        throw(ex);
W20141122-11:01:32.702(-5)? (STDERR)                              ^
W20141122-11:01:32.708(-5)? (STDERR) ReferenceError: Template is not defined
W20141122-11:01:32.709(-5)? (STDERR)     at app/leaderboard.js:13:1
W20141122-11:01:32.710(-5)? (STDERR)     at app/leaderboard.js:17:3
W20141122-11:01:32.710(-5)? (STDERR)     at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:168:10
W20141122-11:01:32.711(-5)? (STDERR)     at Array.forEach (native)
W20141122-11:01:32.712(-5)? (STDERR)     at Function._.each._.forEach (/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141122-11:01:32.712(-5)? (STDERR)     at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

我的研究表明,'Exited with code: 8'是一个通常与尝试更改数据库相关的错误。我对流星很新,很感激投入。

3 个答案:

答案 0 :(得分:1)

确保在Template块中添加了if(Meteor.isClient){}帮助程序代码。如果您在公共区域添加了编码,它也会尝试在服务器端运行代码,显然Template在服务器端不可用。

if (Meteor.isClient) {
  Template.leaderboard.helpers({
    players: function () {
      return "Some other text"
  }
});

答案 1 :(得分:0)

在我的情况下,错误代码相同,即8但堆栈跟踪不同。这是我的堆栈跟踪。

W20150821-20:23:59.161(5.5)? (STDERR) Error: A method named '/players/insert' is already defined
W20150821-20:23:59.161(5.5)? (STDERR)     at packages/ddp/livedata_server.js:1461:1
W20150821-20:23:59.161(5.5)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
W20150821-20:23:59.161(5.5)? (STDERR)     at [object Object]._.extend.methods (packages/ddp/livedata_server.js:1459:1)
W20150821-20:23:59.161(5.5)? (STDERR)     at [object Object].Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:904:1)
W20150821-20:23:59.161(5.5)? (STDERR)     at new Mongo.Collection (packages/mongo/collection.js:209:1)
W20150821-20:23:59.162(5.5)? (STDERR)     at app/leadboard.js:45:15

我正在做点什么。然后我确实备份了我的文件并将其保存在同一个文件夹中。由于其中的声明如下

CollectionName = new Mongo.Collection('collection-name')

在整个项目中出现了两次。这就是我收到此错误的原因。我删除了备份文件,事情已经整理好了。希望将来有人帮助。

答案 2 :(得分:0)

我同样收到同样的错误!

我有代码行

PlayersList = new Mongo.Collection('players');

在我的客户文档和服务器文档中。

看起来这个错误是由于重复或在正确的地方没有收集声明而发生的。