//Add below line in Header
var moment = require(‘moment’);
// and use moment() in your controller.
var startDate = moment().startOf(‘month’);
Replacing, the import with the NPM style require didn’t solve it. Error message remains the same.
@Tomwa : did you import in a client (or shared) file? If you imported only on the server, then moment won’t be available in your client.
I Imported it in a .js file on the Client (Under the Client folder), I have no need of it server side as it’s not privileged information in any way.
In your specific example, your newMoment would actually be set to the current date and time (it’s equivalent to var newMoment = new Date() - is that what you expected?
Yes, though technically I was just trying to see if I imported it correctly. I wished to use it to do necessary date\time calculations (i.e. 5 months, 3 weeks, 6 months since x) without having to account for varying month sizes (and leap years, etc.) myself.
I have yet to get the “moment is not a function” issue resolved.