TypeError: Error resolving module specifier

Viewed 6586

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";
1 Answers

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 ../.

Related