question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot set property '$timezone' of undefined

See original GitHub issue

Exception:

node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError: Cannot set property '$timezone' of undefined
    at M.f.tz (/root/v3/node_modules/dayjs/plugin/timezone.js:1:1271)
    at Function.withdrawalCompleted (/root/v3/dist/core/common/utils/TelegramNotification.js:31:54)
    at EventEmitter.<anonymous> (/root/v3/dist/core/withdrawal/services/status.service.js:124:63)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Code (withdrawalCompleted):

import * as DayJS from 'dayjs'
import * as DayJSTimezone from 'dayjs/plugin/timezone'

DayJS.extend(DayJSTimezone)

export class Notification {
     public static async withdrawalCompleted(withdrawal) {
        const dateText = DayJS(withdrawal.createdAt).tz('Europe/Moscow').format('dd.LL.yyyy HH:mm:ss ZZZZ')
        ...
    }
}

Details:

node v16.5.0
npm v7.19.1
dayjs v1.10.6

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

37reactions
mngucommented, Aug 9, 2021

Ok, Timezone plugin depends on Utc, don’t forget to add it as well !

import DayJS from 'dayjs'
import DayJSUtc from 'dayjs/plugin/utc'
import DayJSTimezone from 'dayjs/plugin/timezone'

DayJS.extend(DayJSUtc)
DayJS.extend(DayJSTimezone)
1reaction
iamkuncommented, Aug 12, 2021

First of all, please extend UTC plugin first

Ok, Timezone plugin depends on Utc, don’t forget to add it as well!

Second, if you still facing some trouble, feel free to reply here with a demo. (https://npm.runkit.com/dayjs)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using of "dayjs/plugin/timezone" causes Uncaught TypeError
Using of "dayjs/plugin/timezone" causes Uncaught TypeError: Cannot set property of undefined.
Read more >
Cannot read property 'setDefault' of undefined in momentjs ...
javascript - TypeError: Cannot read property 'setDefault' of undefined in momentjs,, moment.tz() - Stack Overflow. Stack Overflow for Teams – ...
Read more >
Cannot read property 'timezone' of undefined - Help me!
Hello, I have an issue using the smart actions, I got this error message “Unexpected error with Valider action”.
Read more >
Set Default Timezone
Change default timezone from local time zone to your custom timezone. You can still custom a different timezone in a specific dayjs object....
Read more >
Guides - Moment.js
please create an issue or make a pull request in the momentjs.com repository. ... In particular if Moment TimeZone is in use, this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found