relative time plugin throws: asynchronous error TypeError: v is not a function
See original GitHub issueDescribe the bug Trying to use relative time formatting for relative times less than a minute throws an error:
asynchronous error TypeError: v is not a function
at Object.n.fromToBase (/Users/christophe.taylor/nurx/deploy/node_modules/dayjs/plugin/relativeTime.js:1:1086)
at i (/Users/christophe.taylor/nurx/deploy/node_modules/dayjs/plugin/relativeTime.js:1:510)
at M.n.from (/Users/christophe.taylor/nurx/deploy/node_modules/dayjs/plugin/relativeTime.js:1:1265)
at Object.exports.app_status_table (/Users/christophe.taylor/nurx/deploy/lib/templates.js:190:23)
at run (/Users/christophe.taylor/nurx/deploy/bin/build-deploy.js:240:32)
Expected behavior
Expected to be rendered as less than a minute ago
Information dayjs v1.10.5 (also happened in v1.10.4)
const dayjs = require('dayjs');
const relativeTime = require('dayjs/plugin/relativeTime');
dayjs.extend(relativeTime, {
thresholds: [
{ l: 's', r: 1 },
{ l: 'ss', r: 59, d: 'second' }, // ? 'ss' format does not exist on locale
{ l: 'm', r: 1 },
{ l: 'mm', r: 120, d: 'minute' },
{ l: 'h', r: 1 },
{ l: 'hh', r: 23, d: 'hour' },
{ l: 'd', r: 1 },
{ l: 'dd', r: 29, d: 'day' },
{ l: 'M', r: 1 },
{ l: 'MM', r: 11, d: 'month' },
{ l: 'y' },
{ l: 'yy', d: 'year' }
],
});
const test_date = new Date().getTime() - 30000;
console.log(dayjs(new Date(test_date)).fromNow(true)); // -> asynchronous error TypeError: v is not a function
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:6
Top Results From Across the Web
relative time plugin throws: asynchronous error TypeError: v is not a ...
Describe the bug Trying to use relative time formatting for relative times less than a minute throws an error: asynchronous error TypeError: v...
Read more >TypeError: Object(...) is not a function in Vue - Stack Overflow
The problem is your call to scheduleMeeting in your createMeeting method, or more precicely that you have not actually imported a function, ...
Read more >CoffeeScript
A CoffeeScript => becomes a JS => , a CoffeeScript class becomes a JS class and so on. Major new features in CoffeeScript...
Read more >Errors | Node.js v19.3.0 Documentation
This will not work because the callback function passed to fs.readFile() is called asynchronously. By the time the callback has been called, the...
Read more >chrome.scripting - Chrome Developers
Files are specified as strings that are paths relative to the extension's root ... For instance, the following code will not work, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Got my issue solved. Not sure if it is related to this issue but it had a similar error message. In my case it was because I was updating only some of the default locale settings for
relativeTimelike this:I figured out that if you don’t set ALL of the locale options for the
relativeTimeit will throw this error (or at least very similar error) when dayjs tries to use one of therelativeTimelocale options that you didn’t set onupdateLocaleand doesn’t find it.This is because
updateLocalewill replace the defaultrelativeTimelocale object with the object you set in theupdateLocale. So for example in this case it would not have locale options for h, hh, s, ss etc.The way I fixed this in my use case was to get the default
relativeTimelocale values and just spread those and update the ones I need to update.Hope this helps someone else as well.
Also facing this issue