简体   繁体   English

d3js/Angular 8 应用程序问题

[英]d3js/Angular 8 application issue

I am trying to construct a tube-map with the help of d3js and Angular.我正在尝试在 d3js 和 Angular 的帮助下构建管图。 I am using Angular 8 and d3 version 3.4.13.我正在使用 Angular 8 和 d3 版本 3.4.13。 On doing npm start I'm getting a series of errors.在做 npm 开始时,我遇到了一系列错误。 Any leads on figuring out why that may be happening would be of great help.找出为什么会发生这种情况的任何线索都会有很大帮助。

Here is a link to the repository: https://github.com/reshnaz/Tubemap.git这是存储库的链接: https://github.com/reshnaz/Tubemap.git

I'm getting the below errors:我收到以下错误:

ERROR in./node_modules/xmlhttprequest/lib/XMLHttpRequest.js /node_modules/xmlhttprequest/lib/XMLHttpRequest.js 中的错误
Module not found: Error: Can't resolve 'child_process' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/xmlhttprequest/lib'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/xmlhttprequest/lib”中的“child_process”

ERROR in./node_modules/jsdom/lib/jsdom/browser/index.js /node_modules/jsdom/lib/jsdom/browser/index.js 中的错误
Module not found: Error: Can't resolve 'cssstyle' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/browser'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/browser”中的“cssstyle”

ERROR in./node_modules/jsdom/lib/jsdom/level2/style.js /node_modules/jsdom/lib/jsdom/level2/style.js 中的错误
Module not found: Error: Can't resolve 'cssstyle' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/level2'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/level2”中的“cssstyle”

ERROR in./node_modules/jsdom/lib/jsdom.js /node_modules/jsdom/lib/jsdom.js 中的错误
Module not found: Error: Can't resolve 'fs' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib”中的“fs”

ERROR in./node_modules/jsdom/lib/jsdom/level2/html.js /node_modules/jsdom/lib/jsdom/level2/html.js 中的错误
Module not found: Error: Can't resolve 'fs' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/level2'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib/jsdom/level2”中的“fs”

ERROR in./node_modules/xmlhttprequest/lib/XMLHttpRequest.js /node_modules/xmlhttprequest/lib/XMLHttpRequest.js 中的错误
Module not found: Error: Can't resolve 'fs' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/xmlhttprequest/lib'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/xmlhttprequest/lib”中的“fs”

ERROR in./node_modules/jsdom/lib/jsdom.js /node_modules/jsdom/lib/jsdom.js 中的错误
Module not found: Error: Can't resolve 'request' in '/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib'找不到模块:错误:无法解析“/home/reshma/Documents/Angular/tubemap_project/tubemap-dashboard/node_modules/jsdom/lib”中的“请求”

I cannot believe the problem is caused by anything other than the old version of d3 you are using.我无法相信问题是由您使用的旧版本 d3 以外的任何其他原因引起的。

The errors you are seeing about missing modules are likely to be because you ran npm install and this generated a load of errors which you either failed to notice or deliberately ignored, and tried to proceed anyway as if nothing was wrong.您看到的有关缺少模块的错误可能是因为您运行了npm install ,这会产生大量错误,您要么没有注意到,要么故意忽略了这些错误,并且无论如何都试图继续进行,好像没有任何问题一样。 Or maybe npm install ran fine but your node_modules folder contains a load of cruft left over from the React.js project?或者npm install运行良好,但您的node_modules文件夹包含 React.js 项目遗留的大量垃圾? What happens if you delete your node_modules folder and try running npm install again?如果您删除node_modules文件夹并尝试再次运行npm install会发生什么?

How the original React.js app you mention worked I can't say, especially since you don't provide a link to the GitHub source code you mention.我不能说你提到的原始 React.js 应用程序是如何工作的,特别是因为你没有提供指向你提到的 GitHub 源代码的链接。 Perhaps it used an older version of React, which in turn required other older dependencies.也许它使用了旧版本的 React,而后者又需要其他旧的依赖项。 Deciding to use the latest version of Angular is somewhat at odds with deciding to use such an old version of d3 in the same project.决定使用最新版本的 Angular 与决定在同一项目中使用如此旧版本的 d3 有点不一致。

The only suggestion I have (if it isn't already obvious) is to bite the bullet and upgrade your project to the latest version of d3.我唯一的建议(如果还不是很明显的话)是硬着头皮把你的项目升级到最新版本的 d3。 Yes, you will have to change the way your code calls to d3, as d3 has changed somewhat between version 3 and version 5. But that's just too bad.是的,您将不得不更改代码调用 d3 的方式,因为 d3 在版本 3 和版本 5 之间发生了一些变化。但这太糟糕了。

Deleting node_modules and package-lock.json, followed by npm cache clean and npm install solved the problem.删除 node_modules 和 package-lock.json,然后是 npm 缓存清理和 npm 安装解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM