Unexpected behavior while importing npm module
Im trying to use
dns2
library in my deno project:
And I get this error:
But if I import this library in a different way, then everything works:
Output:
What am I doing wrong?
Deno v1.44.42 Replies
You're doing nothing wrong, it's a problem with the
dns2
package. They only provide code in commonJS format and export a single class as the default export.
That class has a static Packet
member, but a class member is very different from a module export. In JavaScript one cannot destructure class members in import
statements.Thanks.
I forked this package on my github to fix some things. Am I right in thinking that I won't be able to import it locally until I load it into npm? It's pretty hard to adapt the version for deno.