首页 > 解决方案 > 将 React 应用程序部署到 Heroku 时出现问题 - 即使 package.json 在那里也找不到

问题描述

尝试将 React/Express 全栈应用程序部署到 Heroku - 我已经(希望)将所有必要的脚本放在适当的位置以运行生产构建等,但我正在将 git 存储库推送到 Heroku收到以下错误消息:

remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_b6f0fb08/exercise-logger/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_b6f0fb08/exercise-logger/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent 
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.KjmHh/_logs/2021-05-26T14_40_48_002Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! exercise-logger@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix exercise-logger && npm run build --prefix exercise-logger`
remote: npm ERR! Exit status 254
remote: npm ERR! 
remote: npm ERR! Failed at the exercise-logger@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.KjmHh/_logs/2021-05-26T14_40_48_038Z-debug.log

package.json 文件肯定在根目录(exercise-logger)中,所以我真的不明白为什么我会收到这条消息!

我以前从未部署到 Heroku 或除 Github Pages 以外的任何地方,所以我对此很陌生,因此不知道从哪里开始故障排除......任何朝着正确方向的指针将不胜感激!

标签: node.jsreactjsgitherokunpm

解决方案


推荐阅读