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

Cannot read property 'filename' of undefined #60

Open
davekobrenski opened this issue Jan 13, 2023 · 2 comments · May be fixed by #62
Open

Cannot read property 'filename' of undefined #60

davekobrenski opened this issue Jan 13, 2023 · 2 comments · May be fixed by #62

Comments

@davekobrenski
Copy link

Hi, I'm using v7.3.0, and encountering an error "Cannot read property 'filename' of undefined" - it looks like it's related to the epicfail check for 'require.main!.filename' in the create function. The Node docs say that when the entry point is not a CommonJS module, require.main is undefined -- and the entry point of my app is a module, not cjs.

Is there any way around this issue?

I went back to v7.1.0 and everything works. But there's been some nice additions since then, and I'd love to use the latest version.

Thanks!

@davekobrenski
Copy link
Author

This might be relevant?
blueconic/node-oom-heapdump#3 (comment)

... checking if require.main is null and if so, use process.cwd (https://nodejs.org/api/process.html#process_process_cwd)? Or just use https://www.npmjs.com/package/require-main-filename?

@mcqj
Copy link

mcqj commented Jan 19, 2023

Should the value be passed into the create function from cli.js rather than commonJS being presumed?
Then, developers can choose to pass either require.main.filename or import.meta.url depending on whether they are using commonJS or ES modules.

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