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

Impredictible error on first run #17

Open
josedotjs opened this issue Mar 8, 2023 · 2 comments
Open

Impredictible error on first run #17

josedotjs opened this issue Mar 8, 2023 · 2 comments

Comments

@josedotjs
Copy link
Contributor

Hi Nathan, i am testing the new release and have an issue with the relative time plugin, in the first run i get the error
Uncaught (in promise) TypeError: $setup.$dayjs(...).fromNow is not a function
After terminate the process and run
npm run dev again, the project works fine.
May be related with this dayjs issue iamkun/dayjs#1242
Link to test
https://stackblitz.com/edit/github-qiphrf?file=README.md (you can try terminate the first run and execute npm run dev again)

@nathanchase
Copy link
Owner

I too noticed that issue, and I'm not sure why it happens. AFAIK, the module should just work as an extension of a normal Nuxt 3 plugin, like:

// /plugins/dayjs.ts
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

dayjs.extend(relativeTime);

export default defineNuxtPlugin(() => {
  return {
    provide: {
      dayjs,
    },
  };
});

@nathanchase
Copy link
Owner

Please try https://github.com/nathanchase/dayjs/releases/tag/1.0.15 and let me know if it works for you! It did for me locally.

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

2 participants