どうしても書きエラーが解決できないので、どなたかこのコンソールエラーの修正方法を教えてください。コンソールによると、style.css:1
で起きているようです。
Windwos10のXamppで実行しています。
エラー文
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.
ファイル階層は以下の通りです。
Code & ファイル階層
/src index.js style.css index.html
html
1index.html 2 3<!DOCTYPE html> 4<html lang="ja"> 5<head> 6 <meta charset="UTF-8"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>Modern JS</title> 10</head> 11<body> 12 <div id="app"> 13 </div> 14 <script type="module" src="./src/index.js"></script> 15</body> 16</html> 17
JavaScript
1index.js 2 3import "./style.css"; 4 5document.getElementById("app").innerHTML = ` 6<h1>Hello Vanilla!</h1> 7<div> 8 We use the same configuration as Parcel to bundle this sandbox, you can find more 9 info about Parcel 10 <a href="https://parceljs.org" target="_blank" rel="noopener noreferrer">here</a>. 11</div> 12`;
CSS
1style.css 2 3body { 4 font-family: sans-serif; 5 }
試したこと
index.jsのimport "./style.css";
を// import "./style.css";
とコメントアウトすると正常に動きます。
英語でGoogleってもヒントが得られなかったので、こちらに質問しました。何卒宜しくお願い致します。
回答2件
あなたの回答
tips
プレビュー