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

Fix TypeError: moment is not a function #2228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arifsaygili
Copy link

Hey, I have been using Vitejs and Vue3. I was getting the following error while using your npm library.

"TypeError: moment is not a function"

It appears when inserted into the vitejs build, the library tries to use 'moment' however it receives an object instead of moment, the object contains a 'default' property that is the actual moment method.

I've added a check when the package is built via vitejs to check if moment is not a function and whether it has a default property, and if so, override moment with moment.default and continue as usual.

This change fixed the error on our project.

Thanks in advance for this awesome library.

Hey, I have been using Vitejs and Vue3. I was getting the following error while using your npm library.

"TypeError: moment is not a function"

It appears when inserted into the vitejs build, the library tries to use 'moment' however it receives an object instead of moment, the object contains a 'default' property that is the actual moment method.

I've added a check when the package is built via vitejs to check if moment is not a function and whether it has a default property, and if so, override moment with moment.default and continue as usual.

This change fixed the error on our project.

Thanks in advance for this awesome library.
@tinhvqbk
Copy link

@dangrossman Please take a look this PR for error when using Vitejs build

@akki-jat
Copy link

@dangrossman Facing the same issue. Any update?

@akki-jat
Copy link

@arifsaygili Even after your fix I was still getting moment.localData is not a function error so I open new PR which includes you fix as well. #2307

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