简体   繁体   English

无法在共享服务器上托管 create-react-app 构建,获取与 chunk.js 文件相关的 404 错误

[英]Cannot host create-react-app build on shared server, getting 404 errors related to chunk.js file

I am using create-react-app .我正在使用create-react-app Everything works until I go to create a build.一切正常,直到我去创建一个构建。

I run:我跑:

npm run build

The build is created.构建已创建。 I then download the build file and upload to a shared server via cPanel.然后我下载构建文件并通过 cPanel 上传到共享服务器。

When I go to load the website I get the following errors in browser console:当我去加载网站时,我在浏览器控制台中收到以下错误:

Failed to load resource: the server responded with a status of 404 ()
main.a060bf3c.chunk.css:1 Failed to load resource: the server responded with a status of 404 ()
main.b69fe908.chunk.js:1 Failed to load resource: the server responded with a status of 404 ()
(index):1 GET my_url/static/css/main.a060bf3c.chunk.css net::ERR_ABORTED 404
(index):1 GET my_url/static/js/2.57e02e7f.chunk.js net::ERR_ABORTED 404
(index):1 GET my_url/static/js/main.b69fe908.chunk.js net::ERR_ABORTED 404
manifest.json:1 GET my_url/manifest.json 404
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.

I also added my_url to the package.json:我还将 my_url 添加到 package.json:

{
    "homepage" : my_url
}

I had this problem before, when I was using FTP to transfer the build directory to the shared server.我之前遇到过这个问题,当我使用FTP将构建目录传输到共享服务器时。

It seemed that Filezilla was cutting off the large chunk.js file. Filezilla 似乎正在切断大的 chunk.js 文件。 However using cPanel did work, although now it is not.然而,使用 cPanel 确实有效,尽管现在不是。 Do I need to somehow compress the chunk.js file futher.我是否需要以某种方式进一步压缩 chunk.js 文件。 This is not a large application.这不是一个大型应用程序。

Are the files presents on the ftp (even if uncut)?文件是否存在于 ftp 上(即使未剪切)?

  • main.a060bf3c.chunk.css main.a060bf3c.chunk.css
  • 2.57e02e7f.chunk.js 2.57e02e7f.chunk.js
  • main.b69fe908.chunk.js main.b69fe908.chunk.js
  • manifest.json清单文件

If they are not presents, well you just have a ftp connection problem.如果它们不存在,那么您只是有 ftp 连接问题。

If they are presents, you just have to check the static file server configuration, it probably does not check under the good directory.如果它们存在,您只需检查静态文件服务器配置,它可能不会检查好目录下。

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

相关问题 创建 React App(npm run build) 生成包含不需要的 package.json 内容的 chunk.js 文件 - Create React App(npm run build) generates chunk.js file with unwanted content of package.json 部署后反应白屏,错误404 chunk.js - React white screen after deploy, error 404 chunk.js Heroku - 部署 React/Express 应用程序并在请求 chunk.js 文件时在控制台中获取“无法加载资源” - Heroku - Deploying React/Express app and getting 'Failed to load resource' in the console when requesting the chunk.js files Node.js create-react-app构建 - Node.js create-react-app build React 脚本问题:循环加载 chunk.js - React scripts issue: loop loading chunk.js 在 express 服务器上提供 create-react-app 构建文件 - Serving create-react-app build files on express server 延迟加载不会在Angular中创建chunk.js. - Lazy loading doesn't create chunk.js in Angular 使用 Moment JS 创建 React-App:找不到模块“./locale” - Create-React-App with Moment JS: Cannot find module “./locale” 如何在快速后端server.js文件中设置一些值并在create-react-app代码中使用它? - How to set some value in express backend server.js file and use it in create-react-app code? create-react-app 和 svgr 的 webpack 错误 - webpack errors with create-react-app & svgr
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM