ES6 modules in local files - The server responded with a non-JavaScript MIME type

前端 未结 7 928
夕颜
夕颜 2020-11-28 07:07

I get this error:

Failed to load module script: The server responded with a non-JavaScript MIME type of \"\". Strict MIME type checking is enforced fo

7条回答
  •  伪装坚强ぢ
    2020-11-28 07:34

    A simple fix for me that wasn't listed here was this:

    I had an import statement bringing an object from a different file, which I did via this line:

    import { Cell } from './modules/Cell';

    What broke the code and caused the MIME type error was not having .js appended to the end of ./modules/Cell.

    The updated line fixed my problem:

    import { Cell } from './modules/Cell.js';

提交回复
热议问题