¿Cómo usar D3 en Node.js correctamente?

He estado intentando invocar D3 dentro de Node.js. Primero intenté importar d3.v2.js del sitio web de D3 con la etiqueta de script, pero luego leí este hilo:

Quiero ejecutar d3 desde un Cakefile

Donde el autor de D3 aconseja que uno debería 'npm install d3' ... Hice esto, y puedo invocarlo con éxito en la consola de nodo:

dpc@ananda:$ node
> var d3 = require("d3");
undefined
> d3.version;
'2.8.1' 

Sin embargo, cuando intento invocarlo desde app.js con 'node app.js', obtengo:

node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
TypeError: Cannot read property 'BSON' of undefined
at     /Users/dpc/Dropbox/sync/Business/MindfulSound/Development/nad.am/nadam/node_modules/mongoose/node_modules/mongodb/lib/mongodb/index.js:45:44

Me doy cuenta de que en otra parte, el autor de D3 ha especificado claramente que uno debe requerir el lienzo:

https: //github.com/mbostock/d3/blob/master/examples/node-canvas/us-counties.j

como

var Canvas = require("canvas");

pero incluso entonces, (e incluso si requiere específicamente index.js en lugar de d3.v2.js en una declaración require en app.js), no puedo hacer que lo siguiente funcione dentro de una plantilla de Jade:

- script('/javascripts/d3.v2.js')
h1 Dashboard
  section.css-table
    section.two-column
      section.cell
        hr.grey
        h2 Statistics
        #mainGraph
            script(type="text/javascript") 
              var Canvas = require("canvas");
              var w = 400,
                  h = 400,
                  r = Math.min(w, h) / 2,
                  data = d3.range(10).map(Math.random).sort(d3.descending),
                  color = d3.scale.category20(),
                  arc = d3.svg.arc().outerRadius(r),
                  donut = d3.layout.pie();
              var vis = d3.select("body").append("svg")
                  .data([data])
                  .attr("width", w)
                  .attr("height", h);
              var arcs = vis.selectAll("g.arc")
                  .data(donut)
                  .enter().append("g")
                  .attr("class", "arc")
                  .attr("transform", "translate(" + r + "," + r + ")");
              var paths = arcs.append("path")
                  .attr("fill", function(d, i) { return color(i); });
              paths.transition()
                  .ease("bounce")
                  .duration(2000)
                  .attrTween("d", tweenPie);
              paths.transition()
                  .ease("elastic")
                  .delay(function(d, i) { return 2000 + i * 50; })
                  .duration(750)
                  .attrTween("d", tweenDonut);

              function tweenPie(b) {
                b.innerRadius = 0;
                var i = d3.interpolate({startAngle: 0, endAngle: 0}, b);
                return function(t) {
                  return arc(i(t));
                };
              }

              function tweenDonut(b) {
                b.innerRadius = r * .6;
                var i = d3.interpolate({innerRadius: 0}, b);
                return function(t) {
                  return arc(i(t));
                };

      section.cell
        hr.grey
        h2 Achievements

Respuestas a la pregunta(8)

Su respuesta a la pregunta