Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esm support #302

Closed
peterpeterparker opened this issue Mar 10, 2023 · 2 comments
Closed

esm support #302

peterpeterparker opened this issue Mar 10, 2023 · 2 comments

Comments

@peterpeterparker
Copy link

Hi,

I have trouble to using open in my Node esm library because it relies on __dirname.

// Path to included `xdg-open`.
const localXdgOpenPath = path.join(__dirname, 'xdg-open');

At runtime I get following issue:

ReferenceError: __dirname is not defined in ES module scope

Is there a way to polyfill it to support both cjs and esm?

@sindresorhus
Copy link
Owner

@peterpeterparker
Copy link
Author

Awesome, works like a charm. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants