0

My knowledge about how to use node-imported modules in browser-side javascript is still flaky... I want to use apng in a browser, similarly to what is done here. I have thus used npm to install the module, and then I copy/pasted the lib/index.js file into my base directory. I then have a script main.js in which I write:

import APNG from './apng.js';

This script is linked in my HTML file like this:

<script type="module" src="./main.js"></script>

I wrote type="module" because if I do not write that, I get another error in the console: "Uncaught SyntaxError: import declarations may only appear at top level of a module"

Any thoughts on what I am doing wrong?

There are many posts about this kind of error, but the ones I have seen seem to be library-specific or to be node related, whereas in my case I believe I am just missing some basic knowledge about modules and the correct syntax.

sg1234
  • 600
  • 4
  • 19

0 Answers0