frontend/log

[μ—λŸ¬] Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

meroriiDev 2023. 5. 15. 17:15
728x90
λ°˜μ‘ν˜•

 

πŸ“– λͺ©μ°¨

 

     


     

    바닐라 μžλ°”μŠ€ν¬λ¦½νŠΈλ‘œ SPAλ₯Ό κ΅¬ν˜„ν•˜λ˜ 쀑 κΈ°λ³Έμ„ΈνŒ…λΆ€ν„° λ¬Έμ œκ°€ λ°œμƒν–ˆλ‹€...

     

    Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

     

    πŸ’‘ 원인

    λͺ¨λ“ˆμ„ importν•  λ•Œ ν™•μž₯자λͺ…, 경둜 지정을 μ œλŒ€λ‘œ μž…λ ₯ν•˜μ§€ μ•Šμ•„μ„œ λ°œμƒν•˜λŠ” μ—λŸ¬λ‹€.

    λ¦¬μ•‘νŠΈμ—μ„œλŠ” λͺ¨λ“ˆ import μ‹œ .js, ./λ₯Ό μƒλž΅ν•΄λ„ λœλ‹€. ν•˜μ§€λ§Œ 순수 μžλ°”μŠ€ν¬λ¦½νŠΈμ—μ„œ importν•  λ•Œμ—λŠ” λ¦¬μ•‘νŠΈμ²˜λŸΌ ν•˜λ©΄ μ—λŸ¬κ°€ λ°œμƒν•œλ‹€.


    πŸ’‘ ν•΄κ²° 방법

    경둜, ν™•μž₯자λͺ… λ“± λͺ¨λ“  정보λ₯Ό μƒλž΅μ—†μ΄ μž…λ ₯ν•΄μ£Όλ©΄ λœλ‹€!

    ❌ import App from './App';

    ❌ import App from 'App';

    ⭕️ import App from './App.js';



    πŸ’‘ λŠλ‚€μ 

    λ¦¬μ•‘νŠΈλΌλŠ” λΌμ΄λΈŒλŸ¬κ°€ ν™•μ‹€νžˆ 개발자 편의λ₯Ό μœ„ν•΄ λ§Œλ“€μ–΄μ‘Œκ΅¬λ‚˜,,,
    λ‹€ μ•Œμ•„μ„œ ν•΄μ£ΌλŠ”κ±°μ˜€κ΅¬λ‚˜,,,!!!

    728x90
    λ°˜μ‘ν˜•