找不到所需的文件 index.html - Heroku 推送错误
Posted
技术标签:
【中文标题】找不到所需的文件 index.html - Heroku 推送错误【英文标题】:Could not find a required file index.html - Heroku push error 【发布时间】:2019-03-19 00:47:44 【问题描述】:我正在使用 Heroku CLI 将 react-node 应用程序推送到 Heroku。
构建失败,错误是找不到所需的文件 index.html
我已经检查了所有文件和所有内容
不知道我错过了什么?
我在这里被困了一个星期。
请帮帮我
我正在使用 Heroku CLI 将 react-node 应用程序推送到 Heroku。
构建失败,错误是找不到所需的文件 index.html
我已经检查了所有文件和所有内容
不知道我错过了什么?
我在这里被困了一个星期。
请帮帮我
Package.json
"main": "server.js",
"scripts":
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
,
错误:
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 398 bytes | 398.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.9.4
remote: engines.npm (package.json): 6.2.0
remote:
remote: Resolving node version 8.9.4...
remote: Downloading and installing node 8.9.4...
remote: Bootstrapping npm 6.2.0 (replacing 5.6.0)...
remote: npm 6.2.0 installed
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: audited 2601 packages in 4.802s
remote: found 0 vulnerabilities
remote:
remote: Running heroku-postbuild
remote:
remote: > devconnector@1.0.0 heroku-postbuild /tmp/build_cb13714e30f186bd579e6f8f21bf9383
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote:
remote: > jss@9.8.7 postinstall /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/node_modules/jss
remote: > node -e "console.log('\u001b[35m\u001b[1mLove JSS? You can now support us on open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/jss/donate\u001b[0m')"
remote:
remote: Love JSS? You can now support us on open collective:
remote: > https://opencollective.com/jss/donate
remote:
remote: > uglifyjs-webpack-plugin@0.4.6 postinstall /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/node_modules/uglifyjs-webpack-plugin
remote: > node lib/post_install.js
remote:
remote: added 1375 packages from 852 contributors and audited 13755 packages in 46.845s
remote: found 0 vulnerabilities
remote:
remote:
remote: > client@0.1.0 build /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client
remote: > react-scripts build
remote:
**remote: Could not find a required file.
remote: Name: index.html**
remote: Searched in: /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the client@0.1.0 build scr`enter code here`ipt.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.bspBQ/_logs/2018-10-14T10_57_59_194Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! devconnector@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the devconnector@1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.bspBQ/_logs/2018-10-14T10_57_59_208Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! **Push rejected, failed to compile Node.js app.**
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to murmuring-depths-54253.
【问题讨论】:
希望对您有所帮助github.com/mars/… 本地有类似问题。将我的 node_modules 和 package.json 移出客户端位置。 【参考方案1】:我今天也遇到了这个问题,并设法通过从 .gitignore 中删除 /public 文件夹来解决它。
这可能有两个原因:
-
可能您在
.gitignore
中指定了/public
目录
区分大小写的路径
更多信息请访问:https://create-react-app.dev/docs/deployment/#heroku
【讨论】:
【参考方案2】:可能的解决方案:您的文件结构可能是问题
您的“客户”文件夹旁边是否有一个“api”文件夹?
Heroku 似乎不能很好地处理某些文件结构(不知道为什么,我向他们开了一张票询问)
我收到几乎完全相同的错误,因为我的大部分“服务器”文件都位于根目录的 api 文件夹中。
将这些文件移出 api 文件夹,删除我的锁定文件并重新安装节点模块后,部署顺利进行。
所以,尝试以下方法:
确保您的文件结构与标准部署不冲突(请参见下面的屏幕截图)
删除您的锁定文件和 node_modules
在根目录和客户端重新安装 node_modules
提交并尝试另一个部署 -- 如果成功,请告诉我们
如您所见,唯一的区别是这些文件夹在 api 文件夹中的位置(显然,导入/要求路径名也需要更新)
失败的文件夹结构
成功的文件夹结构
【讨论】:
以上是关于找不到所需的文件 index.html - Heroku 推送错误的主要内容,如果未能解决你的问题,请参考以下文章
Teamcity:错误 MSB3147:找不到所需的文件“setup.bin”