错误"文档未定义"执行电子时

时间:2017-07-26 15:14:14

标签: javascript d3.js electron

我想通过使用带有微小的html和js脚本以及d3.js库的Electron创建一个应用程序。

的package.json

{
  "name": "Test_Report9",
"version": "1.0.0",
"main": "report9.js",
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"jsdom": "9.12.0"
}

的JavaScript(report9.js)

const d3 = require('d3');
svg = d3.select("div").append("svg")
    .attr("id", "chart")
    .attr("width", WIDTH)
    .attr("height", HEIGHT);

使用它们,当执行电子($电子路径)时,错误消息"文档未定义"显示。

App threw an error during load
ReferenceError: document is not defined
    at Object.select (/Users/hnishim/node_modules/d3-selection/build/d3-selection.js:925:25)
    at Object.<anonymous> (/Users/hnishim/Documents/MOLCURE/Electron/Test_Report9_3/src/report9.js:11:10)
    at Object.<anonymous> (/Users/hnishim/Documents/MOLCURE/Electron/Test_Report9_3/src/report9.js:426:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at loadApplicationPackage (/usr/local/lib/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:283:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:325:5)

有谁知道原因以及如何解决?

0 个答案:

没有答案