Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
i need help fixing the error: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of ""

I need help fixing the error 'Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.'. my html is:

<!DOCTYPE html>
<html>
<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 game (not multiplayer)</title>
    <style>
        body {
            height: 100vh;
            width: 100vw;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0;
            background-color: black;
        }
        #game-board {
            background-color: #ccc;
            width:100vmin;
            height: 100vmin;
            display: grid;
            grid-template-rows: repeat(21,1fr);
            grid-template-columns: repeat(21, 1fr);
        }
        .snake {
            background-color: hsl(200, 100%, 50%);
            border: .25vmin solid black;
        }

        .food {
            background-color: hsl(50, 100%, 50%);
            border: .25vmin solid black;
        }
    </style>
    <script src='game.js' defer type='module'></script>
</head>
<body>
    <div id='game-board'></div>
</body>
</html>

my game.js code is:

let LastRenderTime = 0;
import{ snake_speed} from './worm.js';
function main(currentTime) {
    window.requestAnimationFrame(main);
    let secondssincelastrender= (currentTime - LastRenderTime) /1000;
    if (secondssincelastrender < 1/snake_speed) return;



    console.log('render');
    LastRenderTime = currentTime;
    update();
    draw();
}
window.requestAnimationFrame(main);

function update () {

}

function draw () {

}

and my worm.js file code is:

export const snake_speed = 1;

I am also opening google by using the terminal command

"Google Chrome.lnk" --allow-file-access-from-files

I would try making it into a server but I think its to risky. you might think to just go to the question ES6 modules in local files - The server responded with a non-JavaScript MIME type, but but i tried everything there and nothing worked. :/ What is wrong with my code that causes this error?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda