18910140161

JavaScript-React应用程序的构建版本提供了错误的CSS和JS文件链接-堆栈溢出

顺晟科技

2022-10-18 12:47:37

48

我一直在做一个名为Simple-Portfolio的简单React项目,GitHub repo:https://github.com/devang47/simple-portfolio.活动站点URL:https://simple-portfolio.pages.dev/。

此项目在开发服务器中运行良好,但在构建应用程序后,在index.html中,指向其他文件的链接出现错误。例如:

// Wrong:
<link rel="icon" type="image/png" sizes="16x16" href="./simple-portfolio/favicon-16x16.png"/>

expected:
<link rel="icon" type="image/png" sizes="16x16" href="./favicon-16x16.png"/>

生产版本控制台上的

错误:

The script from “https://simple-portfolio.pages.dev/simple-portfolio/static/js/3.f84cd7e8.chunk.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.

The script from “https://simple-portfolio.pages.dev/simple-portfolio/static/js/main.2f259d87.chunk.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.

The stylesheet https://simple-portfolio.pages.dev/simple-portfolio/static/css/main.f6d0acc0.chunk.css was not loaded because its MIME type, “text/html”, is not “text/css”. 

Uncaught SyntaxError: expected expression, got '<'

Uncaught SyntaxError: expected expression, got '<'
到目前为止我所尝试

的:

  • 删除节点_模块
  • 正在删除锁定文件
  • 类似问题栈溢出的
  • 全搜索在另一根树枝上
  • 试试。

顺晟科技:

您的应用程序已部署到https://simple-portfolio.pages.dev/该域的根目录,但package.json设置为http://devang47.github.io/simple-portfolio/具有不同的路径。

要解决此问题,请从package.json中删除package.json,重新构建您的应用程序,并将其重新部署到CloudFlare页面。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航