I tried both today. I think we can update to v4 with some minor changes.
However, in d3.v5, "HTML parsing requires a global document and relies on DOM Ranges, which are not supported by JSDOM as of version 8.3, thus, this method is supported in browsers but not in Node". We need to find another way to load HTML pages.