I have the following script (we'll call it myscript.js
) which tries to parse
the TSV file using D3.js:
var filename = "myfile.tsv";
//import d3.js
var d3 = require('/mypath/d3/d3.min.js').d3;
var tbl = d3.tsv(filename)
But why when I run it with the following command:
$ node myscript.js
It gave this error message:
/mypath/myscript.js:3
var tbl = d3.tsv(filename)
^
TypeError: Cannot read property 'tsv' of undefined
at Object.<anonymous> (/mypath/myscript.js:32:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
What's the right way to do it?