简体   繁体   English

“代码8退出”流星应用示例

[英]“Exited with code 8” Sample meteor applications

I am new to Meteor.js and currently working on the "leaderboard" example app. 我是Meteor.js的新手,目前正在研究"leaderboard"示例应用程序。 After inserting a line of code: 插入一行代码后:

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

I received the error in the app's interface: 我在应用程序界面中收到错误:

"Your app is crashing. Here is the latest log." “您的应用程序崩溃了。这是最新的日志。”

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."

I re-saved the file, went into the terminal and stopped the server and restarted it and received this: 我重新保存了文件,进入终端并停止了服务器,然后重新启动它并收到以下消息:

=> 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.

My research has indicated that 'Exited with code: 8' is an error often associated with try to change db's. 我的研究表明, 'Exited with code: 8'是一个错误,通常与尝试更改db有关。 I am very new to meteor and input is appreciated. 我对流星很陌生,感谢您的投入。

Make sure that you added the Template helper code inside if(Meteor.isClient){} block. 确保已在if(Meteor.isClient){}块内添加了Template帮助程序代码。 If you added the coded in a common area it will try to run the code in the server side also and obviously Template is not available in server side. 如果您在公共区域中添加了代码,它将尝试在服务器端也运行代码,并且显然Template在服务器端不可用。

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

In my case the error code was same ie 8 but the stack trace was different. 在我的情况下,错误代码相同,即8,但是堆栈跟踪不同。 This was my stack trace. 这是我的堆栈跟踪。

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

I was working on something. 我正在做某事。 And then I did take the backup of my files and kept it in same folder. 然后,我确实备份了文件并将其保存在同一文件夹中。 Due to which the statement like below 由于以下语句

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

was appearing twice in the whole project. 在整个项目中出现了两次。 That is why I was getting this error. 这就是为什么我得到此错误。 I removed my backup files and things got sorted out. 我删除了备份文件,一切都整理好了。 Hope it helps someone in future. 希望以后能对某人有所帮助。

I similarly received the same error! 我同样收到了同样的错误!

I had the line of code 我有代码行

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

in both my client document and server document. 在我的客户文档和服务器文档中。

It looks like this error happens due to repetition or not having collection declarations in the right place. 看来此错误是由于重复或在正确的位置没有集合声明而发生的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM