dayjs
dayjs copied to clipboard
Impredictible error on first run
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 https://github.com/iamkun/dayjs/issues/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)
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,
},
};
});
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.