Warm tip: This article is reproduced from serverfault.com, please click

其他-即使应用正在运行,Heroku部署也会失败

(其他 - Heroku deployment is failing even though app is running)

发布于 2020-12-02 21:30:17

我已经将我的应用程序从git成功部署到了Heroku,并且启用了自动部署,效果很好。在过去的两周中,出于相同的原因,每次部署都开始失败,即使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
Questioner
Hadar Rosenman
Viewed
11
A Webb 2020-12-03 05:43:06

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

这里是如何使用它的链接。

希望这对你有用。