You load d3 in nodejs context. Try to load it in browser context:

<script src="js/dependencies/d3.min.js"></script>


I installed d3 using npm and had to write this to get it work:

win.on('loaded', function() {
    d3_root =;

Now I can use instead of

As I understand it is because of nwjs context, you are working on "server" side in your script, so you have to choose document first. If you write code directly to html file should be OK.

Related Query