I’m trying to use momentjs on server-side and I’m getting an error “TypeError: moment is not a function”. It works fine on client-side.
Sample code:
import { Meteor } from 'meteor/meteor';
import { TaskCollection } from '/imports/db/taskCollection';
import moment from "moment";
Meteor.publish('tasks', function publishTasks(date) {
console.log(moment().format());
return TaskCollection.find({ userId: this.userId, date});
});
Does it need to be imported in a different way on server-side?
Lodash works fine on server-side but moment doesn’t.
import { Meteor } from 'meteor/meteor';
import { TaskCollection } from '/imports/db/taskCollection';
import _ from 'lodash';
Meteor.publish('tasks', function publishTasks(date) {
console.log(_.last([1]));
return TaskCollection.find({ userId: this.userId, date});
});