Bootstrap-datepicker: $.fn.datepicker is undefined with version 1.6.0 (npm, webpack)

Created on 12 Feb 2016  路  3Comments  路  Source: uxsolutions/bootstrap-datepicker

I'm using boostrap-datepicker with npm and webpack to create a web application.
After a recent update (with "npm update"), a new version (1.6.0) of boostrap-datepicker got installed.

Using this version, $.fn.datepicker is undefined (and datepicker itself is not loaded). When going back to version 1.5.1, datepicker works as expected.

Did something with the initialization of datepicker change from version 1.5.1 to 1.6.0? I checked the paths and imports and the only thing I did was to update boostrap-datepicker (I was going back and forth with the versions, just to check). Version 1.6.0 is not working, version 1.5.1 is (both times tested with jQuery 2.2.0).

awaiting-feedback

Most helpful comment

I had this issue as well, and it turned out to be a missing option in my webpack configuration. In my case, I did not want jQuery to be a part of my bundle, so I had to add an external definition.

externals: {
  jquery: 'jQuery'
}

Then I simply required bootstrap-datepicker with require('bootstrap-datepicker/dist/js/bootstrap-datepicker'); and it resolves jQuery correctly.

See https://webpack.github.io/docs/library-and-externals.html for more details.

All 3 comments

can you provide an example?

can't reproduce.

I think it has to do with this issue https://github.com/Eonasdan/bootstrap-datetimepicker/issues/576 and the requirement of jquery as a dependency.

I have similar issue. Only in my case I am using browserify to require bootstrap-datepicker and I get the dependency requirement message during my build.

I had this issue as well, and it turned out to be a missing option in my webpack configuration. In my case, I did not want jQuery to be a part of my bundle, so I had to add an external definition.

externals: {
  jquery: 'jQuery'
}

Then I simply required bootstrap-datepicker with require('bootstrap-datepicker/dist/js/bootstrap-datepicker'); and it resolves jQuery correctly.

See https://webpack.github.io/docs/library-and-externals.html for more details.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giovannigaspar picture giovannigaspar  路  3Comments

PlippiePlop picture PlippiePlop  路  6Comments

Erwane picture Erwane  路  6Comments

tdm00 picture tdm00  路  5Comments

McNetic picture McNetic  路  6Comments