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

Returns node:internal/modules/cjs/loader in commonjs context #7

Open
timkelty opened this issue Nov 23, 2021 · 2 comments
Open

Returns node:internal/modules/cjs/loader in commonjs context #7

timkelty opened this issue Nov 23, 2021 · 2 comments

Comments

@timkelty
Copy link

console.log(parentModule());
// node:internal/modules/cjs/loader

console.log(module.parent.path);
// /Users/timkelty/Projects/craftcms-webpack/

That latter is what I'm wanting/expecting.

node v16.13.0

@davidmarkclements
Copy link

This is also a problem in ESM:

import parentModule from 'parent-module'

console.log(parentModule()) // prints "node:internal/modules/esm/module_job"

full gist here: https://gist.github.com/davidmarkclements/98669c376f945df8a8f5ea17f0cb0b2c

@kireerik
Copy link

kireerik commented Jun 7, 2023

This one works:

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

3 participants