I am getting TypeError: Error resolving module specifier: d3
when trying to import d3.js library. The project uses npm and the error has been encountered in Firefox.
index.html
<!DOCTYPE html>
<html lang="en">
<header>
<meta charset="utf-8" />
<title>D3</title>
</header>
<body>
<div id="svg"></div>
<script src="./index.js" type="module"></script>
</body>
</html>
index.js
import * as d3 from "d3";
Bare import specifiers like "d3" are still not supported in browsers. Import specifiers should be either an absolute or a relative path to the file. For example, import * as d3 from "./d3.js";
Relative path specifiers should start with /
, ./
, or ../
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With