HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
💌
JJong’s Archive
/
🐻
고민곰인
/
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html".

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html".

Tags
JS
html
생성 일시
Oct 25, 2023 12:55 AM
Status
Done
index.html에 script src를 잘못 지정해서 생긴 문제
 
일단, 서버를 켠 위치가 localhost:3000임에 주의!!
script의 src가 상대경로면, 입력한 url에서 해당 src 경로를 찾는 것이고,
절대경로라면 서버를 켠 위치에서 찾는 것
 
이전1 ) 상대경로x
⇒ localhost:3000/posts 입력하면, /JS/7_autoEditor/posts/src/main.js에서 posts를 입력한 것이므로 xx
<script src="./src/main.js" type="module"></script>
 
이전2) 절대경로..인데 실제 내 파일의 절대 경로를 지정했었음 xx..
⇒ localhost:3000/posts 입력하면, /JS/7_autoEditor/JS/7_autoEditor/src/main.js에서 posts를 입력한 것이므로 xx
<script src="/JS/7_autoEditor/src/main.js" type="module"></script> <!-- or -->
 
이후) O
⇒ /JS/7_autoEditor/src/main.js에서 posts를 입력한 것이므로 올바르다!!
<script src="/src/main.js" type="module"></script>