uetchy / create-create-app

⚡️ Create your own `create-something` app.
MIT License
94 stars 24 forks source link

Cannot read property 'filename' of undefined #60

Open davekobrenski opened 1 year ago

davekobrenski commented 1 year ago

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 commented 1 year ago

This might be relevant? https://github.com/blueconic/node-oom-heapdump/issues/3#issuecomment-360537384

... 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 commented 1 year ago

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.