JS Error - cannot use import statement outside a module
There could be several different reasons that you might see the error “cannot use import statement outside a module” in your JavaScript code.
Here are two quick things to check that might help:
- Make sure that you have the type=”module” attribute set.
- Make sure that you are importing from “dist” directory and not the “src” directory otherwise the file you are importing would be considered unbundled.
See this example where we do set the type to module but we are specifying the src dir instead of they dist dir which can cause a problem.
<script type="module" src="milsymbol-2.1.3/src/milsymbol.js"></script>