尝试在node.js上使用d3包时,我遇到了以下错误。
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000775,
"message": "\n/var/task/node_modules/d3/d3.js:562\n"
},
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000775,
"message": " return n.querySelector(s);\n"
},
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000775,
"message": " ^\n"
},
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000835,
"message": "TypeError: Cannot call method 'querySelector' of undefined\n"
},
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000835,
"message": " at d3_select (/var/task/node_modules/d3/d3.js:562:14)\n"
},
{
"ingestionTime": 1435227001159,
"timestamp": 1435227000835,
"message": " at Object.d3.select (/var/task/node_modules/d3/d3.js:1043:17)\n"
},
我使用了3.5.3和最新的3.5.5,但两者都给出了同样的错误。
我的node.js代码是:
var d3 = require("d3");
var d3MeasureText = require('d3-measure-text');
d3MeasureText.d3 = d3;
var dim = d3MeasureText("Time (days)");
console.dir(dim);
你能帮助我,我做错了什么。谢谢你。