sindresorhus / open

Open stuff like URLs, files, executables. Cross-platform.
MIT License
3.18k stars 219 forks source link

Library doesn't seem to work when importing dynamically? #315

Closed vrseraphin closed 1 year ago

vrseraphin commented 1 year ago

Can't seem to import this library using the import method and have the resultant module work.

When I attempt to use it in this manner: let myOpen = null; import('open').then((mod) => { myOpen = mod; myOpen("https://www.google.com"); });

attempts to use myOpen as a function fail with:

TypeError: myOpen is not a function

Curious if there is a reason why the library doesn't seem to work by dynamic import....or if there is a workaround to get it to work.

sindresorhus commented 1 year ago

This is not the place to ask general Node.js questions. This is a valid package. Any errors with importing is a problem with your code or bundler config.

vrseraphin commented 1 year ago

For those curious... myOpen = mod.default;

resolved the issue.