Reputation: 4318
this time i learn meteor.js :D i learn from example. example that i use now is leaderboard :http://www.meteor.com/examples/leaderboard from native example project I have this folder structure :
leaderboard
|-.meteor
|-leaderboard.css
|-leaderboard.html
|-leaderboard.js
I try to understand meteor.js folder sturcture now, i try to move to be like this :
leaderboard
|-.meteor
|-client
|--leaderboard.css
|-leaderboard.html
|-leaderboard.js
|-public
|-server
I didnt change any code, just create folder and move And after that i start meteor and access localhost:3000 but web didnt work. help me how to solve this problem and please exlpain me how to use private folder :D
thanks
update I try follow instruction. I update my server folder with leadership.
Meteor.startup(function () {
if (Players.find().count() === 0) {
var names = ["Ada Lovelace",
"Grace Hopper",
"Marie Curie",
"Carl Friedrich Gauss",
"Nikola Tesla",
"Claude Shannon"];
for (var i = 0; i < names.length; i++)
Players.insert({name: names[i], score: Math.floor(Random.fraction()*10)*5});
}
});
and my leaderboard.js in /client
i update too with no if(Meteor.isClient)
this is my error :
Your app is crashing. Here's the latest log.
W2036-17:49:01.658(7)? (STDERR) D:\Meteor\leaderboard\.meteor\local\build\programs\server\boot.js:195
W2036-17:49:01.661(7)? (STDERR) }).run();
W2036-17:49:01.662(7)? (STDERR) ^
W2036-17:49:01.663(7)? (STDERR) ReferenceError: Players is not defined
W2036-17:49:01.665(7)? (STDERR) at app/server/leadership.js:2:9
W2036-17:49:01.666(7)? (STDERR) at D:\Meteor\leaderboard\.meteor\local\build\programs\server\boot.js:168:61
W2036-17:49:01.668(7)? (STDERR) at Array.forEach (native)
W2036-17:49:01.669(7)? (STDERR) at Function._.each._.forEach (C:\Users\yoza\AppData\Local\.meteor\tools\e42f0b78d3\lib\node_modules\underscore\underscore.js:79:11)
W2036-17:49:01.671(7)? (STDERR) at D:\Meteor\leaderboard\.meteor\local\build\programs\server\boot.js:168:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
Upvotes: 0
Views: 184
Reputation: 75945
There is code in leadership.js
which needs to be placed in the /server
folder in a .js
file too.
All the code inside if(Meteor.isClient){
is meant to run on the client only. So that should go in the /client
folder. It doesn't need the if(Meteor.isClient){
condition check when it is in the client folder.
Likewise stuff which is in if(Meteor.isServer) {
belongs in the /server
folder.
It doesn't work because the files in /client
only get run on the client side and there are server side parts like the collections which need to be run on the server.
Upvotes: 1