Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

68
Vistas
Why i cant import modules in JS

why i cant import my class when i am using the app.js in my html file?

In the console is always Cannot use import statement outside a module

Html snippet

<!-- Scripts -->
<!-- Bootstrap -->
<script src="assets/plugins/bs/bs.js"></script>
<!-- APP -->
<script src="assets/js/SmashTheHamster.js"></script>
<script src="assets/js/Elements.js"></script>
<script src="assets/js/Session.js"></script>
<script src="assets/js/app.js"></script>

code in app.js (there is this error Cannot use import statement outside a module) and yes i exported my modules with export defaut MODULE

import elements from "./Elements";
import SmashTheHamster from "./SmashTheHamster";

thx for help

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have to specify the type of the script tag using type="module"

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos