Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Error "exportación de token inesperado" en Chrome, "las declaraciones de exportación solo pueden aparecer en el nivel superior de un módulo" en Firefox

En mi archivo snake.html, incluí main.js en el tipo de módulo

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Snake</title> <link rel="icon" href="images/favicon.ico"> <link rel="stylesheet" href="css/snake.css"> </head> <body> <div id="gameBoard"></div> <script src="snake/main.js" type="module"></script> </body> </html>

En main.js, importé algunas variables y funciones de snake.js

 import {speed, update as updateSnake, render as renderSnake} from "./snake.js"; updateSnake();

En snake.js, importé una función de input.js

 import {getDirection} from "./input.js";
 export function update() { const direction = getDirection(); for(let i = 0; i < snakeBody.length; i++) { let segment = snakeBody[i]; segment.x += direction.x; segment.y += direction.y; } console.log("Snake updated"); }

Por último, en input.js tengo una función exportada llamada getDirection

 let direction = {x: 0, y: 0}; let lastDirection = {x: 0, y: 0}; export function getDirection() { lastDirection = direction; return direction; }

No escribí el código completo aquí para simplificar el problema. Cuando abro el archivo snake.html en el navegador con el servidor en vivo, aparece "Error de sintaxis no detectado: 'exportación' de token inesperado" en Chrome. Busqué en todos los resultados de Google que encontré y ninguno funcionó. (también en la función getDirection, dice "se declara 'getDirection' pero su valor nunca se lee". ¿Realmente necesito ayuda?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!