Error importing plot 0.5

I tried out the Plot library on and it works great. I am now trying to use the same codebase on my own site but it gives me error on the import statement -

Uncaught SyntaxError: import declarations may only appear at top level of a module

//Here is the import statement which sits at the top of my js file.
import * as Plot from “”;

Browser is Firefox 103.0.

I tried removing this and adding the script tags to the html page but then I get an error relating to Plot not being defined.

1 Like

Did you specify your script to be a module? Here’s a complete webpage that oughtta work:

<!DOCTYPE html>
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <script type="module">
      import * as Plot from "";
        marks: [Plot.line([[0, 0],[1, 1]])]

The GitHub reference is probably the authoritative place to find this kind of information.


Thank you, this does work.

1 Like