denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.81k stars 5.38k forks source link

[node compact] `yeoman generator` CJS `module.parent.filename` got `Uncaught TypeError: Cannot read properties of undefined (reading 'filename')` #19105

Open loynoir opened 1 year ago

loynoir commented 1 year ago

Keyword

Version

$ deno --version
deno 1.33.2 (release, x86_64-unknown-linux-gnu)
v8 11.4.183.1
typescript 5.0.3

Reproduce

$ deno run -A npm:yo webapp
error: Uncaught TypeError: Cannot read properties of undefined (reading 'filename')
    at Object.<anonymous> (file:///home/vscode/.cache/deno/npm/verdaccio/meow/5.0.0/index.js:15:46)
    at Object.<anonymous> (file:///home/vscode/.cache/deno/npm/verdaccio/meow/5.0.0/index.js:114:4)
    at Module._compile (ext:deno_node/01_require.js:968:34)
    at Object.Module._extensions..js (ext:deno_node/01_require.js:1001:10)
    at Module.load (ext:deno_node/01_require.js:879:32)
    at Function.Module._load (ext:deno_node/01_require.js:713:12)
    at Module.require (ext:deno_node/01_require.js:901:19)
    at require (ext:deno_node/01_require.js:1041:16)
    at Object.<anonymous> (file:///home/vscode/.cache/deno/npm/verdaccio/yo/4.3.1/lib/cli.js:9:14)
    at Object.<anonymous> (file:///home/vscode/.cache/deno/npm/verdaccio/yo/4.3.1/lib/cli.js:190:4)
marvinhagemeister commented 1 year ago

Thanks for filing a report. I'd love to take a look at this but I'm not sure how I can reproduce this error on my end. Do you have a repository you can share where we can run the given command deno run -A npm:yo webapp to reproduce the error?

loynoir commented 1 year ago

@marvinhagemeister

I believe

$ deno run -A npm:yo webapp

is a very neat equivalent, compared to node

$ npm install --global yo generator-webapp
$ yo webapp

And yeoman generate project scaffold.

So, should run command within any empty directory.

marvinhagemeister commented 1 year ago

Thank you for providing the steps to reproduce this issue. I can see the error on my machine now.

Can confirm that the issue is that deno doesn't shim the module.parent property. For reference: Node's documentation has a little passage on how it's supposed to work: https://nodejs.org/api/modules.html#moduleparent .