![](/img/trans.png)
[英]Create React App(npm run build) generates chunk.js file with unwanted content of package.json
[英]Cannot host create-react-app build on shared server, getting 404 errors related to chunk.js file
我正在使用create-react-app 。 一切正常,直到我去創建一個構建。
我跑:
npm run build
構建已創建。 然后我下載構建文件並通過 cPanel 上傳到共享服務器。
當我去加載網站時,我在瀏覽器控制台中收到以下錯誤:
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.
我還將 my_url 添加到 package.json:
{
"homepage" : my_url
}
我之前遇到過這個問題,當我使用FTP將構建目錄傳輸到共享服務器時。
Filezilla 似乎正在切斷大的 chunk.js 文件。 然而,使用 cPanel 確實有效,盡管現在不是。 我是否需要以某種方式進一步壓縮 chunk.js 文件。 這不是一個大型應用程序。
文件是否存在於 ftp 上(即使未剪切)?
如果它們不存在,那么您只是有 ftp 連接問題。
如果它們存在,您只需檢查靜態文件服務器配置,它可能不會檢查好目錄下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.