deepdancer has a demo project. Code here is based on this demo project on the deepdancer-darkmagic branch.

Install deepdancer-callgraph

npm install --save-dev deepdancer-callgraph

Create a script enabling the graph generation

For the example we have call it callgraph.js:

var dependencies = require('deepdancer-demo/dependencies');
var dependenciesCallgraph = require('deepdancer-callgraph');

dependencies.eagerLoad();
console.log(dependenciesCallgraph(dependencies));

Not the console.log is actually making the ouput.

Visualize the graph

You need to have graphviz installed in order to have the dot command available.

node callgraph.js > callgraph.dot
dot -Tsvg callgraph.dot > callgraph.svg

And here you go:

deepdancer demo callgraph

A clear view of your dependencies and a nice way to identify design problems.