Trying to use daterangepicker in meteor 1.2[solved]

Hello, I am trying to use daterangepicker. I have used this package.
When I am implementing I have faced

TypeError: moment.localeData(...).firstDayOfWeek is not a function
    at new DateRangePicker (http://localhost:3000/packages/dangrossman_bootstrap-daterangepicker.js?b2593e9dd348fd77fb38d8a58f6c396d5542207b:106:43)
    at HTMLDivElement.<anonymous> (http://localhost:3000/packages/dangrossman_bootstrap-daterangepicker.js?b2593e9dd348fd77fb38d8a58f6c396d5542207b:1514:40)
    at Function.jQuery.extend.each (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:410:23)
    at jQuery.fn.jQuery.each (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:162:17)
    at $.fn.daterangepicker (http://localhost:3000/packages/dangrossman_bootstrap-daterangepicker.js?b2593e9dd348fd77fb38d8a58f6c396d5542207b:1510:14)
    at null.<anonymous> (http://localhost:3000/app/client/views/dashboard/reports/salesReport.js?9b915175402a771ef93cf0e989f652066c8db49f:13:23)
    at http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3330:22
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3671:12)
    at fireCallbacks (http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3326:12)
    at null.<anonymous> (http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3419:5)

thanks in advance

1 Like

Can you show a piece of code ? For instance the initialization of the DateRangePicker

Template.salesReport.onRendered(function () {
$(function () {

    function cb(start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
    cb(moment().subtract(29, 'days'), moment());
        ranges: {
            'Today': [moment(), moment()],
            'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
            'Last 7 Days': [moment().subtract(6, 'days'), moment()],
            'Last 30 Days': [moment().subtract(29, 'days'), moment()],
            'This Month': [moment().startOf('month'), moment().endOf('month')],
            'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
    }, cb);


1 Like

That’s just the example with predefined ranges, so the issue is not there.

You don’t use firstDayOfWeek directly right ?

What do you have in client/view/dashboard/reports/salesReport.js line 13 (click on the error in your browser because lines may change between the file used by the browser and your original one).

cb(moment().subtract(29, 'days'), moment());
I just call the function.

issue fixed if I use another package

moment.localeData() was added to moment in version 2.8.0, so double check that your app is really referencing a version >= 2.8.0. What happens when you run moment.localeData().firstDayOfWeek() in your browser console? Also, what is your current locale set to: moment.locale()?

moment version is 2.10.6,
moment.localeData().firstDayOfWeek() return 0
and moment.locale() return ‘en’.

I think is package issues. another meteor package is working nice

I don’t think it’s a package issue as I’ve tested it and it works well. That being said, if you’ve found another option and it’s working then great!

1 Like