StephenGrider / FullstackReactCode

Companion repo to https://www.udemy.com/node-with-react-fullstack-web-development
1.39k stars 1.17k forks source link

Unable to launch app on heroku (@ lecture 49) #44

Closed abduong closed 5 years ago

abduong commented 5 years ago

I receive an application error when I try to run heroku open after pushing to the heroku master.
Below is an output of my heroku logs --tail.

The project works if I"m running it locally on localhost:5000

2018-12-24T19:31:45.900464+00:00 app[web.1]: npm ERR! Exit status 1 2018-12-24T19:31:45.900770+00:00 app[web.1]: npm ERR! 2018-12-24T19:31:45.901027+00:00 app[web.1]: npm ERR! Failed at the server@1.0.0 start script. 2018-12-24T19:31:45.901335+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2018-12-24T19:31:45.903229+00:00 app[web.1]: 2018-12-24T19:31:45.903557+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2018-12-24T19:31:45.903769+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-12-24T19_31_45_892Z-debug.log 2018-12-24T19:31:46.045578+00:00 heroku[web.1]: State changed from starting to crashed 2018-12-24T19:31:46.021125+00:00 heroku[web.1]: Process exited with status 1 2018-12-24T19:31:51.589446+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-bayou-54764.herokuapp.com request_id=3ad592e2-93bc-4bb9-b91e-53a123fa0b04 fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:31:58.232581+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/auth/google" host=immense-bayou-54764.herokuapp.com request_id=e0ae4f2a-96c4-4852-84e0-e7aa1ff82a53 fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:33:48.390847+00:00 heroku[web.1]: State changed from crashed to starting 2018-12-24T19:33:51.360139+00:00 heroku[web.1]: Starting process with command npm start 2018-12-24T19:33:55.246869+00:00 app[web.1]: 2018-12-24T19:33:55.246892+00:00 app[web.1]: > server@1.0.0 start /app 2018-12-24T19:33:55.246894+00:00 app[web.1]: > node index.js 2018-12-24T19:33:55.246895+00:00 app[web.1]: 2018-12-24T19:33:56.255148+00:00 app[web.1]: module.js:487 2018-12-24T19:33:56.255193+00:00 app[web.1]: throw err; 2018-12-24T19:33:56.255195+00:00 app[web.1]: ^ 2018-12-24T19:33:56.255197+00:00 app[web.1]: 2018-12-24T19:33:56.255200+00:00 app[web.1]: Error: Cannot find module './models/User' 2018-12-24T19:33:56.255202+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:485:15) 2018-12-24T19:33:56.255207+00:00 app[web.1]: at Function.Module._load (module.js:437:25) 2018-12-24T19:33:56.255209+00:00 app[web.1]: at Module.require (module.js:513:17) 2018-12-24T19:33:56.255211+00:00 app[web.1]: at require (internal/module.js:11:18) 2018-12-24T19:33:56.255212+00:00 app[web.1]: at Object. (/app/index.js:8:1) 2018-12-24T19:33:56.255214+00:00 app[web.1]: at Module._compile (module.js:569:30) 2018-12-24T19:33:56.255216+00:00 app[web.1]: at Object.Module._extensions..js (module.js:580:10) 2018-12-24T19:33:56.255217+00:00 app[web.1]: at Module.load (module.js:503:32) 2018-12-24T19:33:56.255219+00:00 app[web.1]: at tryModuleLoad (module.js:466:12) 2018-12-24T19:33:56.255220+00:00 app[web.1]: at Function.Module._load (module.js:458:3) 2018-12-24T19:33:56.255222+00:00 app[web.1]: at Function.Module.runMain (module.js:605:10) 2018-12-24T19:33:56.255224+00:00 app[web.1]: at startup (bootstrap_node.js:158:16) 2018-12-24T19:33:56.255225+00:00 app[web.1]: at bootstrap_node.js:575:3 2018-12-24T19:33:56.307331+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2018-12-24T19:33:56.307803+00:00 app[web.1]: npm ERR! errno 1 2018-12-24T19:33:56.308083+00:00 app[web.1]: npm ERR! server@1.0.0 start: node index.js 2018-12-24T19:33:56.309183+00:00 app[web.1]: npm ERR! Exit status 1 2018-12-24T19:33:56.309520+00:00 app[web.1]: npm ERR! 2018-12-24T19:33:56.309872+00:00 app[web.1]: npm ERR! Failed at the server@1.0.0 start script. 2018-12-24T19:33:56.310119+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2018-12-24T19:33:56.312753+00:00 app[web.1]: 2018-12-24T19:33:56.313560+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2018-12-24T19:33:56.314137+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-12-24T19_33_56_277Z-debug.log 2018-12-24T19:33:56.429956+00:00 heroku[web.1]: State changed from starting to crashed 2018-12-24T19:33:56.409663+00:00 heroku[web.1]: Process exited with status 1 2018-12-24T19:34:23.816065+00:00 heroku[web.1]: Starting process with command npm start 2018-12-24T19:34:26.556079+00:00 heroku[web.1]: State changed from starting to crashed 2018-12-24T19:34:26.518100+00:00 heroku[web.1]: Process exited with status 1 2018-12-24T19:34:30.218256+00:00 heroku[web.1]: State changed from crashed to starting 2018-12-24T19:34:29.504972+00:00 app[api]: Release v14 created by user ann@canopy.tools 2018-12-24T19:34:29.504972+00:00 app[api]: Set GOOGLE_CLIENT_SECRET config vars by user ann@canopy.tools 2018-12-24T19:34:32.722697+00:00 heroku[web.1]: Starting process with command npm start 2018-12-24T19:34:35.197979+00:00 app[web.1]: 2018-12-24T19:34:35.197995+00:00 app[web.1]: > server@1.0.0 start /app 2018-12-24T19:34:35.197997+00:00 app[web.1]: > node index.js 2018-12-24T19:34:35.197998+00:00 app[web.1]: 2018-12-24T19:34:36.032420+00:00 app[web.1]: module.js:487 2018-12-24T19:34:36.032459+00:00 app[web.1]: throw err; 2018-12-24T19:34:36.032461+00:00 app[web.1]: ^ 2018-12-24T19:34:36.032462+00:00 app[web.1]: 2018-12-24T19:34:36.032464+00:00 app[web.1]: Error: Cannot find module './models/User' 2018-12-24T19:34:36.032466+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:485:15) 2018-12-24T19:34:36.032468+00:00 app[web.1]: at Function.Module._load (module.js:437:25) 2018-12-24T19:34:36.032469+00:00 app[web.1]: at Module.require (module.js:513:17) 2018-12-24T19:34:36.032471+00:00 app[web.1]: at require (internal/module.js:11:18) 2018-12-24T19:34:36.032473+00:00 app[web.1]: at Object. (/app/index.js:8:1) 2018-12-24T19:34:36.032474+00:00 app[web.1]: at Module._compile (module.js:569:30) 2018-12-24T19:34:36.032476+00:00 app[web.1]: at Object.Module._extensions..js (module.js:580:10) 2018-12-24T19:34:36.032477+00:00 app[web.1]: at Module.load (module.js:503:32) 2018-12-24T19:34:36.032479+00:00 app[web.1]: at tryModuleLoad (module.js:466:12) 2018-12-24T19:34:36.032480+00:00 app[web.1]: at Function.Module._load (module.js:458:3) 2018-12-24T19:34:36.032482+00:00 app[web.1]: at Function.Module.runMain (module.js:605:10) 2018-12-24T19:34:36.032483+00:00 app[web.1]: at startup (bootstrap_node.js:158:16) 2018-12-24T19:34:36.032485+00:00 app[web.1]: at bootstrap_node.js:575:3 2018-12-24T19:34:36.047028+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2018-12-24T19:34:36.047400+00:00 app[web.1]: npm ERR! errno 1 2018-12-24T19:34:36.047658+00:00 app[web.1]: npm ERR! server@1.0.0 start: node index.js 2018-12-24T19:34:36.047884+00:00 app[web.1]: npm ERR! Exit status 1 2018-12-24T19:34:36.048034+00:00 app[web.1]: npm ERR! 2018-12-24T19:34:36.048190+00:00 app[web.1]: npm ERR! Failed at the server@1.0.0 start script. 2018-12-24T19:34:36.048595+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2018-12-24T19:34:36.049916+00:00 app[web.1]: 2018-12-24T19:34:36.050159+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2018-12-24T19:34:36.050339+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-12-24T19_34_36_043Z-debug.log 2018-12-24T19:34:36.135042+00:00 heroku[web.1]: State changed from starting to crashed 2018-12-24T19:34:37.161578+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-bayou-54764.herokuapp.com request_id=992467d5-a879-46f4-8016-3de2d039effc fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:34:54.835244+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/auth/google" host=immense-bayou-54764.herokuapp.com request_id=27ff55e1-141e-4565-8159-e54a00a29c56 fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:35:11.906553+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-bayou-54764.herokuapp.com request_id=8fdf7921-0b28-44d6-a3a8-2355a5fcfc4a fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:37:10.967226+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-bayou-54764.herokuapp.com request_id=351d1a90-1106-4c81-a4cf-2e34b7308930 fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:39:17.639779+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/auth/google" host=immense-bayou-54764.herokuapp.com request_id=35ac42a7-8439-4c1c-8013-10ebce49efab fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:42:05.437492+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-bayou-54764.herokuapp.com request_id=3e483aaa-4212-4a93-9a2c-ed2be21a9205 fwd="24.247.108.2" dyno= connect= service= status=503 bytes= protocol=https 2018-12-24T19:45:01.417311+00:00 heroku[web.1]: State changed from crashed to starting 2018-12-24T19:45:05.595865+00:00 app[web.1]: 2018-12-24T19:45:05.595885+00:00 app[web.1]: > server@1.0.0 start /app 2018-12-24T19:45:05.595887+00:00 app[web.1]: > node index.js 2018-12-24T19:45:05.595888+00:00 app[web.1]: 2018-12-24T19:45:06.208919+00:00 heroku[web.1]: State changed from starting to crashed 2018-12-24T19:45:06.190230+00:00 heroku[web.1]: Process exited with status 1


My index.js file looks like this:

const express = require('express'); const mongoose = require('mongoose'); const cookieSession = require('cookie-session'); const passport = require('passport'); const keys = require('./config/keys') require('./models/User'); require('./services/passport');

mongoose.connect(keys.mongoURI);

const app = express();

app.use( cookieSession({ maxAge: 30 24 60 60 1000, keys: [keys.cookieKey] }) );

app.use(passport.initialize()); app.use(passport.session());

require('./routes/authRoutes')(app);

const PORT = process.env.PORT || 5000; app.listen(PORT);