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

Heroku deployment is failing even though app is running

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

I have deployed my app from git to Heroku successfully and I enabled automatic deployment that worked fine. Somewhere in the past 2 weeks the deployment has started failing each time for the same reason, even though there's no problem with the code in the git - it's running fine.

You can see in the log file that it mentions each time:

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

But the MainPage file is right where it should be and the app is compiling and running locally. I've tried disconnecting and reconnecting from git and heroku, I've deleted and re-installed the node modules and the package-lock, and I cache clean --force.

I don't know what went wrong, any suggestions?

Thank you!

-----> 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
0
A Webb 2020-12-03 05:43:06

Your production build may be referencing a relative import that for some reason does not exist. Reconfigure that import using ${__dirname}/path_to_file and try again.

Here is a link of how to use it.

Hope this works for you.