question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1.7.1 version throws "Uncaught TypeError: $(...).datepicker is not a function" when bundled

See original GitHub issue

Expected behaviour

datepicker should work normally as in version 1.7.0

Actual behaviour

In version 1.7.1 browser throws error Uncaught TypeError: $(...).datepicker is not a function

Datepicker version used

1.7.1

Example code

Problem happens when code is bundled with laravel-mix (webpack).

app.js

...
require("bootstrap-datepicker")
...

used in html:

	<script type="text/javascript">
		$(document).ready(function(){
			$('.input-daterange').datepicker({
				format: 'yyyy-mm-dd',
				weekStart: 1,
				autoclose: true
			});
		});
	</script>

Fix

Downgrading back to 1.7.0 helps.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jleidercommented, Mar 23, 2018

Just ran into this exact same issue which cropped up when upgrading node >= 8 due to the differences in the way npm >= 5 manages packages. We use webpack to manage our builds and when running npm >=5 we would wind up with two different versions of jquery being loaded in our builds since we explicitly list jquery as a dependency in our project as does bootstrap-datepicker. When webpack resolves the dependencies, it sees that bootstrap-date picker has its own local dependency and loads that separately from the jquery that was previously imported. I think the real fix is to make jquery a peerDependency and anyone relying on this downstream should need to include jquery explicitly themselves as a dependency. Of course, this should be released with a major sem-version bump to prevent issues like #2206 from being filed again.

2reactions
arutkowski00commented, Oct 9, 2017

I can confirm that it’s not working because jquery is defined in dependencies but it should be in peerDependencies and because of that, yarn is fetching a different version of jquery to node_modules/bootstrap-datepicker/node_modules/jquery.

Version v1.7.0 (with jquery in peerDependencies) works and my recommended workaround is to keep with that version 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: $(...).datepicker is not a function ...
This error is occur,because the function is not defined. In my case i have called the datepicker function without including the datepicker ......
Read more >
Uncaught TypeError: $(...).datepicker is not a function
Hi All,. Getting the following errors for trying get a datetime picker. Create:247 Uncaught TypeError: $(...).datepicker is not a function
Read more >
"Datepicker is not a function" error thrown - Progress Community
An error with message "$(...).datepicker is not a function" is thrown when using the JQuery datepicker. Uncaught TypeError: jQuery(...).
Read more >
$(...).Datepicker Is Not A Function - Jquery - Bootstrap - ADocLib
datepicker is not a function Datepicker version used 1.7.1 Example code Problem happ. 1.7.1 version throws Uncaught TypeError:. @acrobat If it were related ......
Read more >
Datepicker is not defined as function - CodeProject
In the browser, check the developer tools window and see if the bootstrap-datetimepicker.min.js file is actually being found and loaded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found