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

dependencyTree only returning an empty object #152

Open
kb-ig opened this issue Oct 7, 2022 · 2 comments
Open

dependencyTree only returning an empty object #152

kb-ig opened this issue Oct 7, 2022 · 2 comments
Labels

Comments

@kb-ig
Copy link

kb-ig commented Oct 7, 2022

I'm hoping someone can help me understand how to use this, as I seem to be getting an empty object back when using dependencyTree.

I have files along the lines of:

.
└── src/
        ├── file1.js (doesnt depend on anything)
        ├── file2.js (depends on file1.js)
        └── file3.js (depends on file1.js and file2.js)

Above, where I state that a file depends on another, it imports the other file with require().

And I'm trying to get the dependency info like so:

const srcFiles = await fs.readdir('./src/');
const trees = srcFiles.map(filename => dependencyTree({ filename, directory: './src' }));
console.log(trees);

Which outputs:

[ {}, {}, {} ]

Obviously I'm expecting something other than an empty object for each file. If anyone can help me understand how to use this I'd appreciate it.

@XhmikosR
Copy link
Member

Are you by any chance on Node.js 20?

@kb-ig
Copy link
Author

kb-ig commented Nov 22, 2023

@XhmikosR While I cant be sure what I was using back then, I believe it would have been Node 14.

Having just tried to recreate this again now, I get the exact same output on versions 14, 16, 18, 20, 21.

I've created an MRP here.

I expect it's probably me not understanding how to use this library properly.

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

No branches or pull requests

2 participants