2

I have several JavaScript modules structured as shown below:

modules/
  main.js
  canvas.js
  shapes.js
  shapes/
    circle.js
    square.js
    triangle.js 

is main.js, canvas and shapes are imported. in shapes, circle,tringle, square modules are imported. I add a reference to main module in my HTML page like

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

but it has this error: Uncaught SyntaxError: Cannot use import statement outside a module.

can you help me? and can i don not add reference to child modules in html? for example I just add:

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

in HTML and not identifying other modules in HTML.

metodribic
  • 1,561
  • 17
  • 27
Ali
  • 21
  • 2
  • 1
    Does this answer your question? [Why don't self-closing script elements work?](https://stackoverflow.com/questions/69913/why-dont-self-closing-script-elements-work) – jsejcksn Oct 11 '21 at 07:58

0 Answers0