error: Uncaught TypeError: Cannot set property 'dayjs' of undefined
I'm just trying to get started using dayjs using deno 1.9.0. I've downloaded dayjs 1.10.4 using the link the instructions gave me.
Here is my test file calendar.js:
//import * as dayjs from "https://cdn.jsdelivr.net/npm/[email protected]/dayjs.min.js"
import * as dayjs from "./dayjs.js"
let now = dayjs()
console.log ( now )
And here's what I get when I run "deno run calendar.js":
error: Uncaught TypeError: Cannot set property 'dayjs' of undefined
at file:///[SNIP]/testing/dayjs.js:1:143
at file:///[SNIP]/testing/dayjs.js:1:148
Unfortunately since dayjs has been minified, I don't know how to begin to troubleshoot this even further, especially since this is my first attempt to use the library. Am I importing it or doing something else wrong?
Thank you for the suggestion, but I still can't get it to work:
import dayjs from "dayjs" error: relative import path "dayjs" not prefixed with / or ./ or ../ Imported from "file:///[SNIP]/calendar.js"
import dayjs from "./dayjs.js" error: Uncaught SyntaxError: The requested module './dayjs.js' does not provide an export named 'default'
import dayjs from "https://cdn.jsdelivr.net/npm/[email protected]/dayjs.min.js" error: Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/[email protected]/dayjs.min.js' does not provide an export named 'default'
I'm getting the same errors.
@iamkun Any updates to this issue? Even i am getting the same errors when using typescript.
@remdragon Did you end up finding any solution to this?
I did not. I ended up developing my own lightweight date management object.
Royce Mitchell, IT Consultant ITAS Solutions @.***
There are three hard problems in computer science: naming things, and off-by-one errors.
On Mon, Oct 4, 2021 at 11:31 AM Kishan @.***> wrote:
@remdragon https://github.com/remdragon Did you end up finding any solution to this?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iamkun/dayjs/issues/1461#issuecomment-933652635, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4RVVYVYOZJC2C7SGXDRELUFHJENANCNFSM43DLQXWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You can import it using:
import dayjs from "https://cdn.skypack.dev/dayjs";
and you can even import plugins like this:
import timezone from "https://cdn.skypack.dev/dayjs/plugin/timezone";
import utc from "https://cdn.skypack.dev/dayjs/plugin/utc";
Perhaps the README.md file could be updated with a Deno section with small guides as how to use dayjs in Deno.
@shotrifork Above is not working with recent version. Getting this error - cdn.skypack.dev/error/build:[email protected]
This works (in Deno repl):
> import dayjs from "https://esm.sh/[email protected]";
undefined
> dayjs('2018-08-08')
u {
"$L": "en",
"$d": 2018-08-08T04:00:00.000Z,
"$x": {},
"$y": 2018,
"$M": 7,
"$D": 8,
"$W": 3,
"$H": 0,
"$m": 0,
"$s": 0,
"$ms": 0
}
You can also use skypack to import dayjs:
import dayjs from "https://cdn.skypack.dev/[email protected]?dts"