I am new to coding I keep getting this script error when I try to inspect my code in chrome using the developer tools? Any suggestions or help would be appreciated.
snakegame.html:1 Access to script at 'file:///C:/Users/mverm/Desktop/HTML/HTML/Personal%20Projects/snake_game/snakegame.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. snakegame.js:1 Failed to load resource: net::ERR_FAILED
HTML
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Snake Game</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="snakegame.css">
</head>
<body>
<div id="game-board"></div>
<script src="snakegame.js" defer type="module"></script>
</body>
</html>
CSS
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;
}
JS
let lastRenderTime = 0;
function main(currentTime) {
const secondsSinceLastRender = (currentTime - lastRenderTime) / 1000;
window.requestAnimationFrame(main);
lastRenderTime = currentTime;
console.log(secondsSinceLastRender);
}
window.requestAnimationFrame(main);