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";
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";
Share
Improve this question
asked Mar 2, 2020 at 20:17
YuehaiYuehai
1,2431 gold badge11 silver badges20 bronze badges
1
- The answer by @hurried-helpful does answer your question. – Wolfgang Kuehn Commented Oct 13, 2020 at 22:18
1 Answer
Reset to default 6Bare 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 ../
.