Module not found error with "subdir" buildpack
deepan96 opened this issue · 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
> styled-components@5.3.5 postinstall /tmp/build_f1f2b62e/node_modules/styled-components
> node ./postinstall.js
> core-js@3.21.1 postinstall /tmp/build_f1f2b62e/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.21.1 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
> client@0.1.0 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! client@0.1.0 build: react-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@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.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
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: #71 (comment)
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.