Any hints what the following exception might be about?
Running on: http://localhost:3000/
No dependency info in bundle. Filesystem monitoring disabled.
Errors prevented startup:
Exception while bundling application:
Error
at Object.<anonymous> (/usr/local/meteor/lib/node_modules/handlebars/lib/handlebars/utils.js:11:34)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/usr/local/meteor/lib/node_modules/handlebars/lib/handlebars.js:6:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
My HTML:
<head>
<title>dinokiller</title>
</head>
<body>
<div id="outer">
<div>
{{> dinostemp}}
</div>
</div>
</body>
<template name="dinostemp">
{{#each dinos}}
<div>
<img src="{{pix}}"/>
</div>
{{/dinos}}
</template>
And JS:
Dinos = new Meteor.Collection("dinos");
// On server startup, create some dinos if the database is empty.
if (Meteor.is_server) {
Meteor.startup(function () {
if (Dinos.find().count() === 0) {
var dinoPix = ["https://encrypted-tbn2.google.com/images?q=tbn:ANd9GcRwVgHngNuY25hibRmniM1xsVhSlyf_ksctjjVMZ11zmX_kxzfe8w",
"https://encrypted-tbn2.google.com/images?q=tbn:ANd9GcRFcKunc_qEdRzqyPgKGMHdSbwaiaiqGYMr8rfoRtBKNVf_U8O-",
"https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcQbBCccfaS4QqAWrvUSxqyATiKMIitU5YMkdxJfo6ax4dsUxGmmbA",
"https://encrypted-tbn2.google.com/images?q=tbn:ANd9GcTGVyjyj76ppSFsXTF5xjiWLw77oR7d9fxmVkkaj4dhsBWQioRz"];
Dinos.insert({pix:dinoPix[0], div:"11"});
Dinos.insert({pix:dinoPix[1], div:"22"});
Dinos.insert({pix:dinoPix[2], div:"31"});
Dinos.insert({pix:dinoPix[3], div:"44"});
}
});
}
// Set up a collection to contain player information. On the server,
// it is backed by a MongoDB collection named "dinos."
if(Meteor.is_client){
Template.dinostemp.dinos = function(){
return Dinos.find();
};
}
You need {{/each}} to close the loop, not {{/dinos}}.
Error handling around malformed templates is still a work in progress.
Related
This question already has answers here:
Meteor simple-todos tut - Step 2 - Uncaught Error Cannot find module './template.body.js
(4 answers)
Closed 6 years ago.
Whenever I create new directories or files inside 'imports/ui/' the changes are not detected.
The error goes away and everything works fine as soon as I manually restart the server.
Is this behavior intentional? Can I change it so Meteor detects new files automatically?
This is my code:
//client/main.js
import '../imports/ui/body.js';
_
//imports/ui/body.js
import { Template } from 'meteor/templating';
import './body.html';
Template.body.helpers({
tasks: [
{ text: 'This is task 1' },
{ text: 'This is task 2' },
{ text: 'This is task 3' },
],
});
_
//imports/ui/body.html
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
This is the error I get on Chrome's console:
Uncaught Error: Cannot find module './template.body.js'
at require (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:119:19)
at meteorInstall.imports.ui.body.html (http://localhost:3000/app/app.js?hash=daa6958260cc1e0c5e80d55b2d8741e114835c8d:9:18)
at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:191:9)
at Module.require (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:116:16)
at Module.Mp.import (http://localhost:3000/packages/modules.js?hash=d99e0932efe1a420b80cdbd95cd57dc3604a8456:314:16)
at meteorInstall.imports.ui.body.js (http://localhost:3000/app/app.js?hash=daa6958260cc1e0c5e80d55b2d8741e114835c8d:21:99)
at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:191:9)
at Module.require (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:116:16)
at Module.Mp.import (http://localhost:3000/packages/modules.js?hash=d99e0932efe1a420b80cdbd95cd57dc3604a8456:314:16)
at meteorInstall.client.main.js (http://localhost:3000/app/app.js?hash=daa6958260cc1e0c5e80d55b2d8741e114835c8d:38:14)
Set the project's Meteor version to a previous one:
meteor update --release 1.4.1.3
(Thanks to diaconutheodor)
Source
I'm struggling to load templates when using Flow Router. If I include my templates in /client/app.html -
<body>
{{> applicationLayout}}
</body>
<template name="applicationLayout">
<header>
{{> Template.dynamic template=header}}
</header>
</template>
<template name="mainMenu">
<ul>
<li>who we are </li>
<li>what we do</li>
<li>where we work</li>
</ul>
</template>
And my routes in /lib/routes.js -
FlowRouter.route( '/terms', {
action: function() {
BlazeLayout.render( 'applicationLayout', {
header: 'mainMenu',
} );
},
name: 'termsOfService', // Optional route name.
});
Then everything works fine. But I want to split out my templates. So I create /imports/ui/components/main-menu.html
<template name="mainMenu">
<h2> {{currentPage}} </h2>
<ul>
{{#each pages }}
<li> {{ page.headerTitle }} </li>
{{/each}}
</ul>
</template>
I remove the template from /client/app.html and then add the following import to the top of my /lib/routes.js
import '/imports/ui/components/main-menu.js';
Now I get the following error -
/Users/aidan/.meteor/packages/meteor-tool/.1.3.2_4.1s3pnfi++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
throw(ex);
^
Error: Cannot find module './main-menu.html'
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:78:1)
at meteorInstall.imports.ui.components.main-menu.js (imports/ui/components/main-menu.js:5:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
at meteorInstall.lib.routes.js (lib/routes.js:1:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
at /Users/aidan/Code/edu-finance/.meteor/local/build/programs/server/app/app.js:239:1
at /Users/aidan/Code/edu-finance/.meteor/local/build/programs/server/boot.js:283:10
at Array.forEach (native)
Exited with code: 8
Your application is crashing. Waiting for file change.
I can't work out what's going on here. How do I split out my templates?
UPDATE
So I've managed to get somewhere by putting my includes in /client/app.js. This is displaying things as I expected. I'm not sure this is the best way to structure everything. And I'd still love to know what the problem was trying to do the imports in /lib/routes.js
I cant figure out why I am getting this error. I have created a Meteor Method. Maybe I just need a second set of eyes and point out my mistake. Im creating a Instant Messaging App, where online users can have one on one chats. As soon as I click on the online user(routing). The console instantly has an
insert failed:access denied.
If I attempt to send a message, This is the error I get.
j…y.Event {originalEvent: Event, type: "submit", timeStamp:
1455207989065, jQuery1112075371492956765: true, which: undefined…}
meteor.js:862 insert failed: Access denied meteor.js:862 update
failed: Access denied 17799meteor.js:862 insert failed: Access denied
Im really new to Meteor and any help or advice would be very much appreciated.
Here is my HTML
<template name="chat_page">
<h2>Type in the box below to send a message!</h2>
<div class="row">
<div class="col-md-12">
<div class="well well-lg">
{{#each messages}}
{{> chat_message}}
{{/each}}
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<form class="js-send-chat">
<input class="input" type="text" name="chat" placeholder="type a message here...">
<button class="btn btn-default">send</button>
</form>
</div>
</div>
</template>
<!-- simple template that displays a message -->
<template name="chat_message">
<div class = "container">
<div class = "row">
<img src="/{{profile.avatar}}" class="avatar_img">
{{username}} said: {{text}}
</div>
</div>
<br>
</template>
Client Side
Template.chat_page.helpers({
messages:function(){
var chat = Chats.findOne({_id:Session.get("chatId")});
return chat.messages;
},
other_user:function(){
return ""
},
});
Template.chat_page.events({
'submit .js-send-chat':function(event){
console.log(event);
event.preventDefault();
var chat = Chats.findOne({_id:Session.get("chatId")});
if (chat){
var msgs = chat.messages;
if (!msgs){
msgs = [];
}
msgs.push({text: event.target.chat.value});
event.target.chat.value = "";
chat.messages = msgs;
Chats.update(chat._id, chat);
Meteor.call("sendMessage", chat);
}
}
})
Method
Meteor.methods({
sendMessage: function (chat) {
Chats.insert({
chat: chat,
createdAt: new Date(),
username: Meteor.user().profile.username,
avatar: Meteor.user().profile.avatar,
});
},
});
Do you still have insecure and autopublish package ?
Chats.update(chat._id, chat);
This part seems a little weird to me.
a basic update to a collection is : Chats.update({_id : chat._id}, {$set : {message : whateverMymsgis }}); Meteor is kind of strict with the update method you will always need to pass the _id to update something.
If you don't have autopublish and insecure packages, have you made all the allow / publish / subcription part to your collections ??
Hope it will help :)
This has happened because you removed insecure package and have not specified any allow/deny for your chat collection and also your meteor method has been written on the client side.
The quick and proper solution would be moving your meteor method to the server side.
Currently I am on the 3step of the meteor tutorial
The first failure was this command:
meteor mongo
According to google that command now fails due to a known bug.
So, I work around it with this command:
mongo --port 3001
Next I tried this command from the mongo prompt:
dan#u77:~/mets/simple-todos $
dan#u77:~/mets/simple-todos $
dan#u77:~/mets/simple-todos $ mongo --port 3001
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/test
meteor:PRIMARY>
meteor:PRIMARY> db.tasks.insert({ text: "Hello world!", createdAt: new Date() });
WriteResult({ "nInserted" : 1 })
meteor:PRIMARY>
meteor:PRIMARY>
According to the tutorial, I should now see a task in the template.
But, I see nothing.
JAVASCRIPT
// simple-todos.js
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: function () {
return Tasks.find({});
}
});
}
HTML
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
I ran into this issue and the reason it wasn't working was because I'd forgotten to include tasks.js in servers/main.js:
import '../imports/api/tasks.js';
The tutorial does suggest this.
I ran into that issue and that was because I had removed autopublish.
Make sure you have the autopublish package by running:
meteor add autopublish
I have a page which is rendering fine and whenever i refresh the page it is showing exception
like below
Exception from Deps recompute function: TypeError: Cannot read property 'option1' of undefined
at Object.Template.display_poll.helpers.product_title1 (http://localhost:3000/client/xxx.js?9b4f281e748352d5500dbda34a33f155fc8cc293:838:49)
at apply (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:276:24)
at invoke (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:301:12)
at http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:365:30
at Object.Spark.labelBranch (http://localhost:3000/packages/spark.js?742c715b73fac26c16ad433118b87045bc5658ff:1170:14)
at branch (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:355:20)
at http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:364:18
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
at template (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:358:7)
the exception causing line is
product_title1:function() {
var title1=Polls_Coll.findOne({_id:this._id}).option1[0].pd;
return title1;
}
Here is my template
<template name="display_poll">
<!-- displaying poll question -->
{{uniqueid}}
<p class="label-design table-pop-more" name="{{unique_id}}">
<img src="/images/polls.jpg">{{question}}</p>
<div class="table-pop-more">
<div class="poll-options" id="menuitems">
<ul>
<!-- product thumbnails -->
<li><input type="text" class="pad-top" id="{{id_op1}}"
value="{{product_title1}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op2}}"
value="{{product_title2}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op3}}"
value="{{product_title3}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op4}}"
value="{{product_title4}}" readonly/><br></li>
</ul>
</div>
</div>
</template>
Help me with this.
If you want any other information i will provide.
The problem is with Polls_Coll.findOne(). When you load the page, the data from database is not yet fetched, so all find queries are empty – therefore, Polls_Coll.findOne(...) returns undefined. Only later the helper is rerun and findOne returns the actual data.
The simplest solution is to check whether the data is in place:
Template.displayPoll.productTitle = function() {
var poll = Polls_Coll.findOne(this._id);
if(!poll) return '';
return poll.option1[0].pd;
}