简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM