【发布时间】:2018-02-14 09:36:07
【问题描述】:
我正在创建一个个人网站/投资组合,我偶然发现了强大的 gatsby.js 包。
出于研究目的,我还必须可视化一个复杂的数据集,我想使用 d3.js,并将我在 Gatsby 支持的网站中创建的仪表板包括在内。
可以在 react 组件中使用 d3 -> https://medium.com/@Elijah_Meeks/interactive-applications-with-react-d3-f76f7b3ebc71
理论上,Gatsby 应该能够支持 d3 集成,但我的尝试到目前为止都失败了。
这是我尝试过的:
完成盖茨比教程https://www.gatsbyjs.org/tutorial/
我正在使用 gatsbyjs 文档中已完成的第 4 个教程站点,并添加了以下内容
npm install --save d3
添加了 utils/d3.js
文件内容
import d3 from "d3"
module.exports = d3
我还在 gatsby-config.js 插件中添加了 d3。
我运行gatsby develop,收到以下错误,挂起。
success delete html files from previous builds — 0.005 s
success open and validate gatsby-config.js — 0.003 s
(node:8725) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 2): Error: Unable to find plugin "d3"
(node:8725) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated.
In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
任何反馈都会有所帮助,如果这是一个棘手的壮举,那么我实现 d3 集成和简单的个人站点框架目标的阻力最小的路径是什么?
2017 年 9 月 8 日更新
我切换到 Hello World!调试 d3 问题的教程。我试过d3 和d3-node npm 包。
在我的 index.js 文件中添加 import d3 from "d3" 后,我得到两个在引导完成后发生的类似错误。
两个错误都在编译尝试中循环并分别输出:
d3 错误
ERROR Failed to compile with 2 errors
These dependencies were not found:
* child_process in ./~/xmlhttprequest/lib/XMLHttpRequest.js
* fs in ./~/xmlhttprequest/lib/XMLHttpRequest.js
To install them, you can run: npm install --save child_process fs
d3 节点错误 将 index.js 上的导入切换为“d3-node”
ERROR Failed to compile with 13 errors
These dependencies were not found:
* fs in ./~/jsdom/lib/jsdom.js, ./~/jsdom/lib/jsdom/browser/resource-loader.js and 3 others
* net in ./~/tough-cookie/lib/cookie.js, ./~/forever-agent/index.js and 1 other
* child_process in ./~/jsdom/lib/jsdom/living/xmlhttprequest.js
* tls in ./~/forever-agent/index.js, ./~/tunnel-agent/index.js
To install them, you can run: npm install --save fs net child_process tls
These relative modules were not found:
* ../file-api/FileReader-impl.js in ./~/jsdom/lib/jsdom/living/generated/FileReader.js
* ../events/MutationEvent-impl.js in ./~/jsdom/lib/jsdom/living/generated/MutationEvent.js
【问题讨论】:
标签: javascript node.js d3.js svg gatsby