Reputation: 5013
I am new in meteor. I doest add moment.js in my package. But I can see moment.js is included in my rendered page. I think moment.js included by any other package which is added by me. My question is I can't use that included moment.js. When I try to use moment.js Meteor says Exception in template helper: ReferenceError: moment is not defined
. What might be the problem?
Js:
Template.Home.helpers({
fromnow: function(time){
console.log(time);
return moment(time).fromNow();
}
});
Upvotes: 0
Views: 1634
Reputation: 6018
the simple answer to this is that you have to actually add that package to Meteor. The HTML source that you are showing is just the dependency indicator. You will have to add the package manually from command line.
command is as follows:
>meteor add momentjs:moment
momentjs:moment: Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging
The above line indicates that the momentjs package is installed. So now, wherever you might have written the code for moment. It will start working.
Upvotes: 3