Heroku 部署失败,即使应用程序 运行

Heroku deployment is failing even though app is running

我已成功将我的应用程序从 git 部署到 Heroku,并且我启用了自动部署,效果很好。 在过去 2 周的某个时间里,由于同样的原因,部署每次都开始失败,即使 git 中的代码没有问题 - 运行 很好。

你可以在日志文件中看到它每次都提到:

" Creating an optimized production build...
       Failed to compile.
       ./src/App.js
       Cannot find file './pages/MainPage' in './src'.

但是 MainPage 文件就在它应该在的位置,应用程序正在编译并且 运行 在本地。 我试过从 git 和 heroku 断开连接并重新连接, 我已经删除并重新安装了节点模块和包锁, 我 cache clean --force.

我不知道哪里出了问题,有什么建议吗?

谢谢!

-----> React.js (create-react-app) multi app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
=====> Detected Framework: Multipack
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
=====> Detected Framework: Node.js
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.20.0...
       Using default npm version: 6.14.8
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules
       
       > core-js@2.6.12 postinstall /tmp/build_826a0ec4_/node_modules/babel-runtime/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > fsevents@1.2.13 install /tmp/build_826a0ec4_/node_modules/webpack-dev-server/node_modules/fsevents
       > node install.js
       
       
       Skipping 'fsevents' build as platform linux is not supported
       
       > fsevents@1.2.13 install /tmp/build_826a0ec4_/node_modules/watchpack-chokidar2/node_modules/fsevents
       > node install.js
       
       
       Skipping 'fsevents' build as platform linux is not supported
       
       > core-js@3.8.0 postinstall /tmp/build_826a0ec4_/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > fsevents@1.2.13 install /tmp/build_826a0ec4_/node_modules/jest-haste-map/node_modules/fsevents
       > node install.js
       
       
       Skipping 'fsevents' build as platform linux is not supported
       
       > core-js-pure@3.8.0 postinstall /tmp/build_826a0ec4_/node_modules/core-js-pure
       > node -e "try{require('./postinstall')}catch(e){}"
       
       added 1695 packages in 29.379s
       
-----> Build
       Running build
       
       > rosenflix@0.1.0 build /tmp/build_826a0ec4_
       > react-scripts build
       
       Creating an optimized production build...
       Failed to compile.
       
       ./src/App.js
       Cannot find file './pages/MainPage' in './src'.
       
       
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rosenflix@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the rosenflix@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.Zqszt/_logs/2020-12-02T21_16_51_485Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile React.js (create-react-app) multi app.
 !     Push failed

您的生产版本可能引用了由于某种原因不存在的相对导入。使用 ${__dirname}/path_to_file 重新配置该导入,然后重试。

Here 是关于如何使用它的 link。

希望这对你有用。