create-react-app-buildpack icon indicating copy to clipboard operation
create-react-app-buildpack copied to clipboard

Module not found error with "subdir" buildpack

Open deepan96 opened this issue 3 years ago • 2 comments

I am trying to deploy my react app to heroku which runs perfectly fine on local. But I keep seeing the error "Module not found: Error: Can't resolve './redux/store' in '/tmp/build_f1f2b62e/src' " even though the file is present. Any help is appreciated. I am also attaching the build log below:

-----> Building on the Heroku-20 stack -----> Using buildpacks: 1. https://github.com/timanovsky/subdir-heroku-buildpack.git 2. heroku/nodejs -----> Subdir buildpack app detected -----> Subdir buildpack in client creating cache: /tmp/codon/tmp/cache created tmp dir: /tmp/codon/tmp/cache/subdir9DNL7 moving working dir: client to /tmp/codon/tmp/cache/subdir9DNL7 cleaning build dir /tmp/build_f1f2b62e copying preserved work dir from cache /tmp/codon/tmp/cache/subdir9DNL7 to build dir /tmp/build_f1f2b62e cleaning tmp dir /tmp/codon/tmp/cache/subdir9DNL7 -----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=false

-----> Installing binaries engines.node (package.json): 14.8.0 engines.npm (package.json): unspecified (use default)

   Resolving node version 14.8.0...
   Downloading and installing node 14.8.0...
   Using default npm version: 6.14.7

-----> Restoring cache Caching has been disabled because NODE_MODULES_CACHE=false

-----> Installing dependencies Installing node modules

   > [email protected] postinstall /tmp/build_f1f2b62e/node_modules/styled-components
   > node ./postinstall.js
   
   
   > [email protected] postinstall /tmp/build_f1f2b62e/node_modules/core-js
   > node -e "try{require('./postinstall')}catch(e){}"
   
   
   > [email protected] postinstall /tmp/build_f1f2b62e/node_modules/core-js-pure
   > node -e "try{require('./postinstall')}catch(e){}"
   
   added 1585 packages in 18.786s

-----> Build Running build

   > [email protected] build /tmp/build_f1f2b62e
   > react-scripts build
   
   Creating an optimized production build...
   Failed to compile.
   
   Module not found: Error: Can't resolve './redux/store' in '/tmp/build_f1f2b62e/src'

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: react-scripts build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] 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.u2qg2/_logs/2022-04-27T05_20_08_537Z-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
   
   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/
   
   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

deepan96 avatar Apr 27 '22 18:04 deepan96

Module not found / Can't resolve errors during build are typically due to differences between the committed files and how they are referenced in the code.

See: https://github.com/mars/create-react-app-buildpack/issues/71#issuecomment-385723967

mars avatar Apr 27 '22 18:04 mars

Also, I notice you're using https://github.com/timanovsky/subdir-heroku-buildpack.git in this app.

Based on what that buildpack does during build (promoting a subdirectory to be the root for build), this may be causing ./redux/store to be missing.

mars avatar Apr 28 '22 14:04 mars