Use npm's Arborist to get a dependency tree for a package.
const getDepTree = require('get-dep-tree');
const { Node } = require('@npmcli/arborist');
const assert = require('assert');
getDepTree().then((tree) => {
assert.ok(tree instanceof Node);
});