简体   繁体   English

加载模块脚本失败:服务器以“text/plain”的非 JavaScript MIME 类型响应。 严格的 MIME 类型检查 i

[英]Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking i

while building a debug toolbar in Django I am getting an error in file toolbar.js ie.在 Django 中构建调试工具栏时,我在文件 toolbar.js 中遇到错误,即。 s.map: HTTP error: status code 404, net:: ERR_UNKNOWN_URL_SCHEME toolbar.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". s.map:HTTP 错误:状态码 404,net::ERR_UNKNOWN_URL_SCHEME toolbar.js:1 无法加载模块脚本:服务器以“text/plain”的非 JavaScript MIME 类型响应。 Strict MIME type checking is enforced for module scripts per HTML spec.根据 HTML 规范对模块脚本强制执行严格的 MIME 类型检查。

can anyone tell me the possible fix for that?谁能告诉我可能的解决方法?

I found solution here How to set content type of JavaScript files in Django我在这里找到了解决方案How to set content type of JavaScript files in Django

#settings.py
if DEBUG:
    import mimetypes
    mimetypes.add_type("application/javascript", ".js", True)

Expanding on drewslee answer扩展drawslee的答案

The solution to the problem is indicated in the documentation问题的解决方案在文档中说明

  • For Windows, you need to edit the registry.对于 Windows,您需要编辑注册表。 Set HKEY_CLASSES_ROOT\.js\Content Type to text/javascript .HKEY_CLASSES_ROOT\.js\Content Type设置为text/javascript

I have faced the problem and it was fixed after edit the Windows registry.我遇到了这个问题,并且在编辑 Windows 注册表后得到了修复。 I just Set HKEY_CLASSES_ROOT.js\Content Type from text/plain to text/javascript.我只是将 HKEY_CLASSES_ROOT.js\Content Type 从 text/plain 设置为 text/javascript。

Now the problem is solved!现在问题解决了!

I faced the same error.我遇到了同样的错误。 It was resolved once I updated the HKEY_CLASSES_ROOT.js\Content Type from text/plain to text/javascript in my Windows using RegistryEditor .一旦我使用RegistryEditor在我的 Windows 中将HKEY_CLASSES_ROOT.js\Content Typetext/plain更新为text/javascript ,它就解决了。

After that I had to refresh my browser cache to be able to see the toolbar之后,我必须刷新浏览器缓存才能看到工具栏

就我而言,我尝试在另一台服务器(如 8080)上运行它并且它可以工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载模块脚本失败:服务器以“text/plain”的非 JavaScript MIME 类型响应。 对模块强制执行严格的 MIME 类型检查 - Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module 加载模块脚本失败:服务器以非 JavaScript MIME 类型“”响应。 强制执行严格的 MIME 类型检查 - Failed to load module script: The server responded with a non-JavaScript MIME type of “”. Strict MIME type checking is enforced 无法加载模块脚本:服务器以“text/plain”的非 JavaScript MIME 类型响应 - Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain" 加载模块脚本失败:服务器以非 JavaScript、CSS MIME 类型“text/x-scss”响应 - Failed to load module script: The server responded with a non-JavaScript, CSS MIME type of “text/x-scss” Vue.js 3 - “加载模块脚本失败:服务器以非 JavaScript MIME 类型“text/html”响应 - Vue.js 3 - “Failed to load module script: The server responded with a non-JavaScript MIME type of ”text/html" Flask:加载模块脚本失败:服务器以“text/html”的非 JavaScript MIME 类型响应 - Flask: Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html” 加载模块脚本失败:服务器响应非 JavaScript MIME 类型“” - Failed to load module script: The server responded with a non-JavaScript MIME type of "" 服务器以“application/octet-stream”的非 JavaScript MIME 类型响应 每个 HTML 对模块脚本强制执行严格的 MIME 类型检查 - The server responded with a non-JavaScript MIME type of "application/octet-stream" Strict MIME type checking is enforced for module scripts per HTML 从'./image.jpeg'结果导入图像无法加载模块脚本服务器以非JavaScript MIME类型“ image / jpegerror”响应 - Import image from './image.jpeg' results Failed to load module script The server responded with a non-JavaScript MIME type of "image/jpegerror 服务器以“text/html”的非 JavaScript MIME 类型响应 - 节点 - The server responded with a non-JavaScript MIME type of "text/html" - Node
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM