node-dependency-tree icon indicating copy to clipboard operation
node-dependency-tree copied to clipboard

No dependencies shown for executable Node.js script w/o any filename extension

Open hiroshi-ishii opened this issue 1 year ago • 0 comments

I have an executable Node.js script (www) with a shebang (#!) which includes foo.js which in turn includes bar.js: www:

#!/usr/bin/env node
const foo = require("./foo");

foo.js:

const bar = require("./bar");

bar.js

// empty

If I run the dependency-tree CLI on www, I get no dependencies:

$ npx dependency-tree -d . www | jq
{
  "/Users/hiroshi/www": {}
}

If I rename www to www.js, I get the expected result

$ npx dependency-tree -d . www.js | jq
{
  "/Users/hiroshi/www.js": {
    "/Users/hiroshi/foo.js": {
      "/Users/hiroshi/bar.js": {}
    }
  }
}

Environment:

$ npx dependency-tree --version
11.0.1
$ node --version
v18.20.4

hiroshi-ishii avatar Nov 06 '24 04:11 hiroshi-ishii