erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

Deploy to Heroku error with webpack-isomorphic-tools #183

Closed mattjstar closed 9 years ago

mattjstar commented 9 years ago

I tried to deploy a fork of the most recent master code to heroku and I'm getting the following error:

2015-09-11T13:39:49.921006+00:00 heroku[web.1]: Starting process with command `node ./bin/server.js`
2015-09-11T13:39:53.023337+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:54.028752+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:55.030908+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:56.032466+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:57.034563+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:58.036016+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:39:59.037285+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:00.042810+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:01.044237+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:02.045716+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:03.047030+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:04.048994+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:05.049742+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:06.050701+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:07.052019+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:08.054934+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:09.058236+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:10.060174+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:11.062100+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:12.062599+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:13.070200+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:14.071734+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:15.074035+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:16.083350+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:17.093033+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:18.094801+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:19.102577+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:20.110579+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:21.188461+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:22.190858+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:23.222602+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:24.223778+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:25.227615+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:26.229278+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:27.230588+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:28.232054+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:29.233762+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:30.234665+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:31.235917+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:32.238579+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:33.240639+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:34.243125+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:35.255975+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:36.257433+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:37.259235+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:38.259736+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:39.261054+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:40.262579+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:41.264029+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:42.265488+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:43.267105+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:44.268845+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:45.270212+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:46.271662+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:47.273113+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:48.274556+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:49.276066+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:50.278581+00:00 app[web.1]: [webpack-isomorphic-tools] (waiting for the first Webpack build to finish)
2015-09-11T13:40:50.419886+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-11T13:40:50.419886+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-11T13:40:51.530662+00:00 heroku[web.1]: Process exited with status 137
2015-09-11T13:40:51.551459+00:00 heroku[web.1]: State changed from starting to crashed
erikras commented 9 years ago

If you're deploying from a git repo, you need to

npm run build
git add -f webpack-stats.json
git add -f static/dist/*

...every time you deploy. See heroku branch.

mattjstar commented 9 years ago

awesome that got me closer thanks!

Now I'm unfortunately getting this error:

2015-09-11T14:51:47.757938+00:00 app[web.1]: module.js:338
2015-09-11T14:51:47.757942+00:00 app[web.1]:     throw err;
2015-09-11T14:51:47.757943+00:00 app[web.1]:           ^
2015-09-11T14:51:47.757947+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-09-11T14:51:47.757945+00:00 app[web.1]: Error: Cannot find module 'containers'
2015-09-11T14:51:47.757953+00:00 app[web.1]:     at Object.<anonymous> (/app/src/routes.js:2:35)
2015-09-11T14:51:47.757956+00:00 app[web.1]:     at normalLoader (/app/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
2015-09-11T14:51:47.757950+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-09-11T14:51:47.757949+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-09-11T14:51:47.757957+00:00 app[web.1]:     at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
2015-09-11T14:51:47.757959+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-09-11T14:51:47.757960+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-09-11T14:51:47.757951+00:00 app[web.1]:     at require (module.js:384:17)
2015-09-11T14:51:47.757954+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-09-11T14:51:48.875486+00:00 heroku[web.1]: State changed from starting to crashed

...which was fixed by being explicit with the location of that file, but I don't want to now have to do that with all my directory declarations.

I tried deploying your heroku branch and got the same error. Have you seen that before?

erikras commented 9 years ago

Hmmm.... I just pulled the current master into the heroku branch, and it seems to be working.

mattjstar commented 9 years ago

weird, still getting the error even on a brand new untouched heroku app pushing your new heroku branch and running the 3 commands (build) above. Do you have any configuration that I'm missing, buildpacks, etc?

erikras commented 9 years ago

My heroku config variables are:

NODE_ENV          production
NODE_PATH         ./src

I suspect the latter is what you're missing.

mattjstar commented 9 years ago

That did it, thanks so much for all your help!

erikras commented 9 years ago

:+1:

mattjstar commented 9 years ago

For future reference I don't know if you want to add this to the readme on the heroku branch, but it wasn't super clear how to deploy to heroku. I can put together a PR if you need:

https://github.com/wework/react-redux-universal-hot-example/commit/9fc232b884099db898b70bd9fe94087800b172fd

nicolasiensen commented 9 years ago

Hey guys, do you know why I'm getting this?

2015-09-11T18:19:22.762207+00:00 heroku[web.1]: Starting process with command `npm start`
2015-09-11T18:19:25.022522+00:00 app[web.1]:
2015-09-11T18:19:25.022542+00:00 app[web.1]: > hub-client@1.0.0 start /app
2015-09-11T18:19:25.022544+00:00 app[web.1]: > node ./node_modules/better-npm-run start
2015-09-11T18:19:25.022545+00:00 app[web.1]:
2015-09-11T18:19:25.186908+00:00 app[web.1]: running better-npm-run in /app
2015-09-11T18:19:25.195291+00:00 app[web.1]: Executing script: start
2015-09-11T18:19:25.195295+00:00 app[web.1]:
2015-09-11T18:19:25.198024+00:00 app[web.1]: to be executed:PORT=8080 NODE_ENV=production NODE_PATH=./src node ./bin/server.js
2015-09-11T18:19:29.171393+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2015-09-11T18:19:29.171397+00:00 app[web.1]: designed for a production environment, as it will leak
2015-09-11T18:19:29.171399+00:00 app[web.1]: memory, and will not scale past a single process.
2015-09-11T18:19:31.226206+00:00 app[web.1]: [webpack-isomorphic-tools] [error] asset not found: ./node_modules/font-awesome/scss/font-awesome.scss
2015-09-11T18:19:31.224728+00:00 app[web.1]: [webpack-isomorphic-tools] [error] asset not found: ./app/styles/main.scss
2015-09-11T18:19:40.547357+00:00 app[web.1]: ==> ✅  Server is listening
2015-09-11T18:19:40.551921+00:00 app[web.1]: ----------
2015-09-11T18:19:40.551924+00:00 app[web.1]: ==> 💻  Open http://localhost:8080 in a browser to view the app.
2015-09-11T18:19:40.551704+00:00 app[web.1]: ==> 🌎  React Redux Example Production running on port 8080, API on port 3030
2015-09-11T18:20:23.072426+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2015-09-11T18:20:23.037595+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-11T18:20:23.037595+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-11T18:20:23.917009+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-11T18:20:23.894423+00:00 heroku[web.1]: Process exited with status 22

If I'm not mistaken, Heroku doesn't allow you to choose the ports where you want to run your processes, does it?

Thanks!

mattjstar commented 9 years ago

Are you using a Procfile? If you look at the heroku branch to start up on the dyno he doesn't use npm start he does the following in the Procfile, bypassing the port issue allowing it to use the port from the env in config.js

web: node ./bin/server
nicolasiensen commented 9 years ago

Thanks @mattjstar, it worked!

bdefore commented 8 years ago

Note also that you may see the same error if you haven't done your npm build step before running npm start