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

How does this work with ESM Node? #30

Open
NullVoxPopuli opened this issue Jan 23, 2022 · 1 comment
Open

How does this work with ESM Node? #30

NullVoxPopuli opened this issue Jan 23, 2022 · 1 comment

Comments

@NullVoxPopuli
Copy link

there is no require or module (afaik) in ESM, so is there a way to get pkginfo in ESM Node?

@msalafia
Copy link

msalafia commented Nov 28, 2022

I am using the following to access my package.json info for ESM projects:

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const packageJson = require("./package.json");  // <--- change the path to your packege.json accordingly

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