Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: moment is not a function at new DateRangePicker2. How do I resolve it? #261

Open
Mansukh-jsx opened this issue Aug 16, 2022 · 9 comments

Comments

@Mansukh-jsx
Copy link

image

@skratchdot
Copy link
Owner

from https://github.com/skratchdot/react-bootstrap-daterangepicker#getting-started

Install the needed peer dependencies: npm install --save bootstrap-daterangepicker react jquery moment

@Foraminiferatrv
Copy link

Foraminiferatrv commented Jan 30, 2023

I have the same issue using Vite.js. Installing the needed peer dependencies doesn't help. If there's any ideas, please, help.

@skratchdot
Copy link
Owner

try including moment via a script tag:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js" integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

from:
https://cdnjs.com/libraries/moment.js

here is an example of it working with vite:
https://codesandbox.io/p/sandbox/delicate-https-p684rd

@Foraminiferatrv
Copy link

try including moment via a script tag:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js" integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

from: https://cdnjs.com/libraries/moment.js

here is an example of it working with vite: https://codesandbox.io/p/sandbox/delicate-https-p684rd

It worked for me! Thank you so much!

@Jay-zalavadia
Copy link

Jay-zalavadia commented May 2, 2023

Try the below code by adding in entry file : -

import moment from "moment-timezone";
OR
import moment from "moment";

window.moment = moment;

There is no need to add any script tag if library is already installed .

@Nahid570
Copy link

Nahid570 commented Aug 1, 2023

Try the below code by adding in entry file : -

import moment from "moment-timezone"; OR import moment from "moment";

window.moment = moment;

There is no need to add any script tag if library is already installed .

Isn't Working

@felipebluiz
Copy link

try including moment via a script tag:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js" integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

from: https://cdnjs.com/libraries/moment.js

here is an example of it working with vite: https://codesandbox.io/p/sandbox/delicate-https-p684rd

Thanks!!

@billpebert
Copy link

Try the below code by adding in entry file : -

import moment from "moment-timezone"; OR import moment from "moment";

window.moment = moment;

There is no need to add any script tag if library is already installed .

Hi @Jay-zalavadia
i also have kind of error in my daterangepicker configuration, i tried to use cdn and it works. But i wonder why it's not working from this import js config.
I'm using Laravel v.10 and Vite
any suggestions?

image

image

@web4social
Copy link

I'm also using Laravel v.10 and Vite, same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants