achingbrain / ssdp

Simple Service Discovery Protocol implemented for Node.js
Other
53 stars 19 forks source link

Import error in SSDP related to Upgrade of nat-port-mapper from 1.0.8 to 1.0.9 #47

Open justin0mcateer opened 1 year ago

justin0mcateer commented 1 year ago

Apologies for posting this issue here, Issues do not seem to be enabled on the 'nat-port-mapper' repository.

We have 'nat-port-mapper' as a transitive dependency of libp2p. When the nat-port-mapper package is upgraded from 1.0.8 to 1.0.9, we see a reproducible runtime import error. Overriding this to 1.0.8 eliminates the issue. I am not sure what is causing the problem, perhaps the change in version of the build tool (aegir)?

Error

Uncaught TypeError: (0 , import_module.createRequire) is not a function
    at default-ssdp-options.ts:8:13
(anonymous) @ default-ssdp-options.ts:8

Crash point

const req = createRequire(import.meta.url)

The SSDP library hasn't changed at all, so I assume it must be some issue with the bundling? I don't know anything about aegir, so I can't really dig into this much further.

layinka commented 12 months ago

+1 on this

achingbrain commented 11 months ago

Issues do not seem to be enabled on the 'nat-port-mapper' repository.

They're enabled now, sorry about that.

I assume it must be some issue with the bundling?

Are you seeing this error in a browser context? This module is really only supported on node.js - createRequire is exported by the node core "module" module.

If not, can you provide a runnable example so I can reproduce this & fix it?