'DateRangePicker is not defined

I am trying to use this lib: https://github.com/themesberg/tailwind-datepicker

webpack.mix.js file:

mix.setPublicPath('htdocs');
mix.js('resources/js/app.js', 'htdocs/js').
    js('resources/js/dateRangePicker.js', 'htdocs/js');

resources/js/dateRangePicker.js file:

import DateRangePicker from '@themesberg/tailwind-datepicker/DateRangePicker';

app.blade file
...

<script type="module" src="{{mix('js/dateRangePicker.js')}}"></script>
<script>
   const dateRangePickerEl = document.getElementById('datepickstart');
   new DateRangePicker(dateRangePickerEl, {
     // options
   }
</script>

...

But i am getting error in console:

Uncaught ReferenceError: DateRangePicker is not defined

What am I doing wrong and what is the best way to import and work with js modules?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source