Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Error resolving module specifier

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";
like image 246
Taro Yehai Avatar asked Mar 02 '20 20:03

Taro Yehai


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

like image 174
Hurried-Helpful Avatar answered Nov 19 '22 07:11

Hurried-Helpful