Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

martin cartledge
martin cartledge
1,933 Points

Error Deploying React App on Heroku...

I set up my React app and now I am ready to deploy. I've followed the steps provided to simply host on Heroku but, I'm hitting errors when I git push heroku master.

Here's my terminal printout:

remote: =====> Downloading Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git
remote: =====> Detected Framework: React.js (create-react-app)
remote:        Using existing `static.json`
remote:        Enabling runtime environment variables
remote: 
remote: > Portfolio@0.1.0 build /tmp/build_941045d52a01bfc1698a689e5b44c6ac
remote: > node scripts/build.js webpack
remote: 
remote: Creating an optimized production build...
remote: Failed to compile.
remote: 
remote: Module not found: Error: Cannot resolve module 'react-router' in /tmp/build_941045d52a01bfc1698a689e5b44c6ac/src
remote: 
remote: 
remote: npm ERR! Linux 3.13.0-105-generic
remote: npm ERR! argv "/tmp/build_941045d52a01bfc1698a689e5b44c6ac/.heroku/node/bin/node" "/tmp/build_941045d52a01bfc1698a689e5b44c6ac/.heroku/node/bin/npm" "run" "build"
remote: npm ERR! node v6.9.1
remote: npm ERR! npm  v3.10.8
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! Portfolio@0.1.0 build: `node scripts/build.js webpack`
remote: npm ERR! Exit status 1
remote: npm ERR! 
remote: npm ERR! Failed at the Portfolio@0.1.0 build script 'node scripts/build.js webpack'.
remote: npm ERR! Make sure you have the latest version of node.js and npm installed.
remote: npm ERR! If you do, this is most likely a problem with the Portfolio package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system
remote: npm ERR!     node scripts/build.js webpack
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR!     npm bugs Portfolio
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR!     npm owner ls Portfolio
remote: npm ERR! There is likely additional logging output above.
remote: 
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR!     /tmp/build_941045d52a01bfc1698a689e5b44c6ac/npm-debug.log
remote:  !     Push rejected, failed to compile React.js (create-react-app) multi app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to ancient-temple-10539.
remote: 
To https://git.heroku.com/ancient-temple-10539.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/ancient-temple-10539.git'

Any ideas?

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Did you remember to use --save when you installed react-router so it would be added to your package.json file?

martin cartledge
martin cartledge
1,933 Points

Thank you, I was missing that as a dependency.