[英]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 上(即使未剪切)?
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.