Error deploying MERN application to Heroku - node.js

The app successfully deploys but when I try to open the app, I get the following error:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
I ran -heroku logs --tail and I get the following:
deons-mbp:shrinkURL deonchoi$ heroku logs --tail
2019-12-13T02:59:25.356685+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T02:59:25.356952+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T02:59:25.357905+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T02:59:25.358057+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T02:59:25.358220+00:00 app[web.1]: npm ERR!
2019-12-13T02:59:25.358348+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T02:59:25.358480+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T02:59:25.362742+00:00 app[web.1]:
2019-12-13T02:59:25.362837+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T02:59:25.362931+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T02_59_25_359Z-debug.log
2019-12-13T02:59:25.446611+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T02:59:25.422394+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:00:38.195196+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=99378587-a922-4ad8-8445-aca15eba268a fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:38.710170+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=ba6a84fe-9a4b-433d-a00d-1a6231e0317c fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:49.612623+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=7fb228bc-9e62-4526-a51e-feff9631e266 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:50.201204+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=ada57278-8d33-4569-b3e3-bad6b136a234 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:03:11.014926+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-13T03:03:13.149581+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-13T03:03:15.545496+00:00 app[web.1]:
2019-12-13T03:03:15.545520+00:00 app[web.1]: > backend#1.0.0 start /app
2019-12-13T03:03:15.545522+00:00 app[web.1]: > node server.js
2019-12-13T03:03:15.545524+00:00 app[web.1]:
2019-12-13T03:03:16.082886+00:00 app[web.1]:
2019-12-13T03:03:16.082936+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:541
2019-12-13T03:03:16.082939+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-12-13T03:03:16.082942+00:00 app[web.1]: ^
2019-12-13T03:03:16.086177+00:00 app[web.1]: Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-12-13T03:03:16.086180+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11)
2019-12-13T03:03:16.086183+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:541:11)
2019-12-13T03:03:16.086185+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:328:15)
2019-12-13T03:03:16.086187+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:16:10)
2019-12-13T03:03:16.086189+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-13T03:03:16.086191+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-13T03:03:16.086193+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-13T03:03:16.086195+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-13T03:03:16.086197+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
2019-12-13T03:03:16.086200+00:00 app[web.1]: at internal/main/run_main_module.js:17:11 {
2019-12-13T03:03:16.086203+00:00 app[web.1]: message: 'The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.',
2019-12-13T03:03:16.086205+00:00 app[web.1]: name: 'MongooseError'
2019-12-13T03:03:16.086207+00:00 app[web.1]: }
2019-12-13T03:03:16.092626+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T03:03:16.092996+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T03:03:16.094046+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T03:03:16.094306+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T03:03:16.094539+00:00 app[web.1]: npm ERR!
2019-12-13T03:03:16.094740+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T03:03:16.094919+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T03:03:16.104750+00:00 app[web.1]:
2019-12-13T03:03:16.105020+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T03:03:16.105275+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T03_03_16_095Z-debug.log
2019-12-13T03:03:16.178860+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T03:03:16.164865+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:03:24.145385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=ca564a1c-156c-484a-9354-ce243b3b1ed5 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:03:24.586560+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=bb81ead2-cd04-462f-9ab9-64b84d9238bb fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:08:40.000000+00:00 app[api]: Build started by user deon.choi#gmail.com
2019-12-13T03:08:55.468949+00:00 app[api]: Deploy 67508aba by user deon.choi#gmail.com
2019-12-13T03:08:55.468949+00:00 app[api]: Release v4 created by user deon.choi#gmail.com
2019-12-13T03:08:55.741086+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-13T03:08:56.000000+00:00 app[api]: Build succeeded
2019-12-13T03:08:57.971434+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-13T03:08:59.915432+00:00 app[web.1]:
2019-12-13T03:08:59.915464+00:00 app[web.1]: > backend#1.0.0 start /app
2019-12-13T03:08:59.915467+00:00 app[web.1]: > node server.js
2019-12-13T03:08:59.915470+00:00 app[web.1]:
2019-12-13T03:09:00.319828+00:00 app[web.1]:
2019-12-13T03:09:00.319851+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:541
2019-12-13T03:09:00.319854+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-12-13T03:09:00.319857+00:00 app[web.1]: ^
2019-12-13T03:09:00.322625+00:00 app[web.1]: Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-12-13T03:09:00.322629+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11)
2019-12-13T03:09:00.322632+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:541:11)
2019-12-13T03:09:00.322634+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:328:15)
2019-12-13T03:09:00.322636+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2019-12-13T03:09:00.322639+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-13T03:09:00.322641+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-13T03:09:00.322644+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-13T03:09:00.322646+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-13T03:09:00.322648+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
2019-12-13T03:09:00.322651+00:00 app[web.1]: at internal/main/run_main_module.js:17:11 {
2019-12-13T03:09:00.322654+00:00 app[web.1]: message: 'The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.',
2019-12-13T03:09:00.322657+00:00 app[web.1]: name: 'MongooseError'
2019-12-13T03:09:00.322660+00:00 app[web.1]: }
2019-12-13T03:09:00.331200+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T03:09:00.331487+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T03:09:00.333012+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T03:09:00.333312+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T03:09:00.333487+00:00 app[web.1]: npm ERR!
2019-12-13T03:09:00.333633+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T03:09:00.333752+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T03:09:00.341621+00:00 app[web.1]:
2019-12-13T03:09:00.341770+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T03:09:00.341887+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T03_09_00_334Z-debug.log
2019-12-13T03:09:00.424560+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T03:09:00.403174+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:09:01.483310+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=79b75979-00fa-4994-a5d1-4f73c5841172 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:02.191776+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=93cf4327-3365-4174-a2df-7545952b00a6 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:03.076316+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=a2492372-c679-4144-acd1-7956692ad1e0 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:03.469741+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=d14e6638-96d5-4f19-8701-03ab766969fc fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:47.050280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=287c82b4-b3a6-42cc-81c5-ed97f310f7d3 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:47.349496+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=b1ced555-16fd-4255-92be-486d0917aff1 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
I thought the issue was with my mongoose.connect() statement but it seems as if that is not the case.
Here is my server.js express file:
const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');
const cookieParser = require('cookie-parser');
const path = require('path');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
app.use(cookieParser());
const dbURI = process.env.DB_CONNECTION;
mongoose.connect(dbURI, {useNewUrlParser: true, useUnifiedTopology: true});
const connection = mongoose.connection;
connection.once('open', () => {
console.log('MongoDB database connection established successfully');
});
const urlsRouter = require('./routes/urls');
const redirectRouter = require('./routes/index');
const authRoute = require('./routes/auth');
app.use('/api/urls', urlsRouter);
app.use('/api/user', authRoute);
app.use('/api', redirectRouter);
app.use(express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'build', 'index.html'));
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`)
});

refer the following to set environment variable to be used:
https://devcenter.heroku.com/articles/config-vars
The env variable that requires to be set is : DB_CONNECTION

Related

node:internal/modules/cjs/loader:998 when running heroku logs --tail

I am trying to deploy my app to Heroku, however, i am running into some problems that i don't understand. I searched for similar problems but to no success. I ran heroku open but it only displays application error.
The error below is after committing then typing heroku logs --tail
2022-10-27T15:29:24.523556+00:00 heroku[web.1]: Process exited with status 1
2022-10-27T15:29:24.587530+00:00 heroku[web.1]: State changed from starting to crashed
2022-10-27T15:59:56.758114+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vaulteer.herokuapp.com request_id=1cc5af25-d8cc-4fc0-a8db-562612eba0e1 fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-27T16:00:32.097214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vaulteer.herokuapp.com request_id=93cf8986-eb7b-4e9f-995e-846f4f08c8c1 fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-27T16:01:09.820661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vaulteer.herokuapp.com request_id=c94e620d-2c3c-42e1-820b-763011dd8e58 fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-27T16:01:15.043521+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vaulteer.herokuapp.com request_id=cbe6c51b-5bc6-4898-ac5f-f5ba77bb488d fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-27T18:07:29.924304+00:00 heroku[web.1]: State changed from crashed to starting
2022-10-27T18:07:36.794181+00:00 heroku[web.1]: Starting process with command `npm start`
2022-10-27T18:07:38.902356+00:00 app[web.1]: npm WARN config production Use `--omit=dev` instead.
2022-10-27T18:07:38.915737+00:00 app[web.1]:
2022-10-27T18:07:38.915738+00:00 app[web.1]: > password-manager#1.0.0 start
2022-10-27T18:07:38.915739+00:00 app[web.1]: > node server/server.js
2022-10-27T18:07:38.915739+00:00 app[web.1]:
2022-10-27T18:07:38.984836+00:00 app[web.1]: node:internal/modules/cjs/loader:998
2022-10-27T18:07:38.984840+00:00 app[web.1]: throw err;
2022-10-27T18:07:38.984841+00:00 app[web.1]: ^
2022-10-27T18:07:38.984841+00:00 app[web.1]:
2022-10-27T18:07:38.984841+00:00 app[web.1]: Error: Cannot find module './debug'
2022-10-27T18:07:38.984842+00:00 app[web.1]: Require stack:
2022-10-27T18:07:38.984842+00:00 app[web.1]: - /app/node_modules/debug/src/node.js
2022-10-27T18:07:38.984842+00:00 app[web.1]: - /app/node_modules/debug/src/index.js
2022-10-27T18:07:38.984842+00:00 app[web.1]: - /app/node_modules/finalhandler/index.js
2022-10-27T18:07:38.984843+00:00 app[web.1]: - /app/node_modules/express/lib/application.js
2022-10-27T18:07:38.984843+00:00 app[web.1]: - /app/node_modules/express/lib/express.js
2022-10-27T18:07:38.984843+00:00 app[web.1]: - /app/node_modules/express/index.js
2022-10-27T18:07:38.984844+00:00 app[web.1]: - /app/server/server.js
2022-10-27T18:07:38.984844+00:00 app[web.1]: at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
2022-10-27T18:07:38.984845+00:00 app[web.1]: at Module._load (node:internal/modules/cjs/loader:841:27)
2022-10-27T18:07:38.984845+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1061:19)
2022-10-27T18:07:38.984845+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:103:18)
2022-10-27T18:07:38.984864+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/debug/src/node.js:14:28)
2022-10-27T18:07:38.984865+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1159:14)
2022-10-27T18:07:38.984865+00:00 app[web.1]: at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
2022-10-27T18:07:38.984865+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1037:32)
2022-10-27T18:07:38.984865+00:00 app[web.1]: at Module._load (node:internal/modules/cjs/loader:878:12)
2022-10-27T18:07:38.984866+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1061:19) {
2022-10-27T18:07:38.984866+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-10-27T18:07:38.984866+00:00 app[web.1]: requireStack: [
2022-10-27T18:07:38.984866+00:00 app[web.1]: '/app/node_modules/debug/src/node.js',
2022-10-27T18:07:38.984867+00:00 app[web.1]: '/app/node_modules/debug/src/index.js',
2022-10-27T18:07:38.984867+00:00 app[web.1]: '/app/node_modules/finalhandler/index.js',
2022-10-27T18:07:38.984867+00:00 app[web.1]: '/app/node_modules/express/lib/application.js',
2022-10-27T18:07:38.984868+00:00 app[web.1]: '/app/node_modules/express/lib/express.js',
2022-10-27T18:07:38.984868+00:00 app[web.1]: '/app/node_modules/express/index.js',
2022-10-27T18:07:38.984868+00:00 app[web.1]: '/app/server/server.js'
2022-10-27T18:07:38.984868+00:00 app[web.1]: ]
2022-10-27T18:07:38.984869+00:00 app[web.1]: }
2022-10-27T18:07:38.984873+00:00 app[web.1]:
2022-10-27T18:07:38.984874+00:00 app[web.1]: Node.js v18.12.0
2022-10-27T18:07:39.125526+00:00 heroku[web.1]: Process exited with status 1
2022-10-27T18:07:39.324865+00:00 heroku[web.1]: State changed from starting to crashed
2022-10-27T19:52:09.765683+00:00 heroku[web.1]: State changed from crashed to starting
2022-10-27T19:52:16.335694+00:00 heroku[web.1]: Starting process with command `npm start`
2022-10-27T19:52:18.194757+00:00 app[web.1]: npm WARN config production Use `--omit=dev` instead.
2022-10-27T19:52:18.206356+00:00 app[web.1]:
2022-10-27T19:52:18.206357+00:00 app[web.1]: > password-manager#1.0.0 start
2022-10-27T19:52:18.206358+00:00 app[web.1]: > node server/server.js
2022-10-27T19:52:18.206358+00:00 app[web.1]:
2022-10-27T19:52:18.269847+00:00 app[web.1]: node:internal/modules/cjs/loader:998
2022-10-27T19:52:18.269852+00:00 app[web.1]: throw err;
2022-10-27T19:52:18.269852+00:00 app[web.1]: ^
2022-10-27T19:52:18.269852+00:00 app[web.1]:
2022-10-27T19:52:18.269852+00:00 app[web.1]: Error: Cannot find module './debug'
2022-10-27T19:52:18.269853+00:00 app[web.1]: Require stack:
2022-10-27T19:52:18.269853+00:00 app[web.1]: - /app/node_modules/debug/src/node.js
2022-10-27T19:52:18.269853+00:00 app[web.1]: - /app/node_modules/debug/src/index.js
2022-10-27T19:52:18.269854+00:00 app[web.1]: - /app/node_modules/finalhandler/index.js
2022-10-27T19:52:18.269854+00:00 app[web.1]: - /app/node_modules/express/lib/application.js
2022-10-27T19:52:18.269854+00:00 app[web.1]: - /app/node_modules/express/lib/express.js
2022-10-27T19:52:18.269854+00:00 app[web.1]: - /app/node_modules/express/index.js
2022-10-27T19:52:18.269855+00:00 app[web.1]: - /app/server/server.js
2022-10-27T19:52:18.269855+00:00 app[web.1]: at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
2022-10-27T19:52:18.269875+00:00 app[web.1]: at Module._load (node:internal/modules/cjs/loader:841:27)
2022-10-27T19:52:18.269875+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1061:19)
2022-10-27T19:52:18.269876+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:103:18)
2022-10-27T19:52:18.269876+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/debug/src/node.js:14:28)
2022-10-27T19:52:18.269876+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1159:14)
2022-10-27T19:52:18.269876+00:00 app[web.1]: at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
2022-10-27T19:52:18.269877+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1037:32)
2022-10-27T19:52:18.269877+00:00 app[web.1]: at Module._load (node:internal/modules/cjs/loader:878:12)
2022-10-27T19:52:18.269877+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1061:19) {
2022-10-27T19:52:18.269878+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-10-27T19:52:18.269878+00:00 app[web.1]: requireStack: [
2022-10-27T19:52:18.269878+00:00 app[web.1]: '/app/node_modules/debug/src/node.js',
2022-10-27T19:52:18.269879+00:00 app[web.1]: '/app/node_modules/debug/src/index.js',
2022-10-27T19:52:18.269879+00:00 app[web.1]: '/app/node_modules/finalhandler/index.js',
2022-10-27T19:52:18.269879+00:00 app[web.1]: '/app/node_modules/express/lib/application.js',
2022-10-27T19:52:18.269880+00:00 app[web.1]: '/app/node_modules/express/lib/express.js',
2022-10-27T19:52:18.269880+00:00 app[web.1]: '/app/node_modules/express/index.js',
2022-10-27T19:52:18.269880+00:00 app[web.1]: '/app/server/server.js'
2022-10-27T19:52:18.269881+00:00 app[web.1]: ]
2022-10-27T19:52:18.269881+00:00 app[web.1]: }
2022-10-27T19:52:18.269886+00:00 app[web.1]:
2022-10-27T19:52:18.269886+00:00 app[web.1]: Node.js v18.12.0
2022-10-27T19:52:18.395749+00:00 heroku[web.1]: Process exited with status 1
2022-10-27T19:52:18.468515+00:00 heroku[web.1]: State changed from starting to crashed
2022-10-28T01:03:27.021615+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vaulteer.herokuapp.com request_id=e8f46d28-87c5-459a-9e84-81209a3ff372 fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-28T01:03:28.182114+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vaulteer.herokuapp.com request_id=02c2c4df-ff96-4491-ba6d-3d330c7df316 fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-28T01:15:16.563295+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vaulteer.herokuapp.com request_id=487bf4d4-bf13-447b-8903-c497bba1920c fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
2022-10-28T01:15:17.834727+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vaulteer.herokuapp.com request_id=7efbd535-ae24-452d-b72f-863889409f4f fwd="49.145.42.80" dyno= connect= service= status=503 bytes= protocol=https
Honestly, i havent tried anything that much besides npm install as this is the first time ive experienced this problem.
I had a similar error.
I used the node map command to run the file.
Even though my file was called main.js
But the node map command runs the map.js file
After I changed the command to node main everything worked.

NodeJS app deployed on heroku issue - not retrieving data from database

I'm having an issue with my full-stack application, (MySQL-Express-React-NodeJS). I have deployed it to Heroku everything is working except the pages that are connected to get or post to ClearDB MySQL database! Any advises or hints on something that I might have forgot to do? I'm also using the ClearDB add-on from Heroku if that helps.
server.js:
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
const http = require("http");
const server = http.createServer(app);
const connection = require("./app/Models/database");
// require user the route
const user = require("./app/routes/user");
// require the doctor route
const doctor = require("./app/routes/doctor");
// require the question route
const questions = require("./app/routes/questions.js");
// require the schedule route
const schedule = require("./app/routes/schedule");
const appointement = require("./app/routes/appointment");
const socket = require("socket.io");
const io = socket(server);
app.use(cors());
// set the port
const port = process.env.PORT || 5000;
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// define the user router
app.use("/users", user);
app.use("/doctor", doctor);
app.use("/questions", questions);
app.use("/schedule", schedule);
app.use("/appointment", appointement);
app.use(function (error, req, res, next) {
if (error instanceof SyntaxError) {
//Handle SyntaxError here.
return res.status(500).send({ data: "Invalid data" });
} else {
next();
}
});
const peers = {};
io.on("connection", (socket) => {
//
if (!peers[socket.id]) {
peers[socket.id] = socket.id;
}
socket.emit("yourID", socket.id); // allows you to emit custom events on the server and client
io.sockets.emit("allUsers", peers); //will send to all the clients ......socket.broadcast.emit will send the message to all the other clients except the newly created connection
socket.on("disconnect", () => {
delete peers[socket.id]; //after the user leave the room
});
socket.on("callUser", (data) => {
io.to(data.userToCall).emit("hello", {
signal: data.signalData,
from: data.from,
}); //io.to('some room').emit('some event');
});
socket.on("acceptCall", (data) => {
io.to(data.to).emit("callAccepted", data.signal);
});
});
//test route
app.get("/test", function (req, res) {
res.send( "test");
});
app.listen(port, () => {
console.log(`Server is Running on port ${port}`);
});
Heroku logs:
2021-01-04T18:46:17.729977+00:00 heroku[web.1]: Restarting
2021-01-04T18:46:17.732430+00:00 heroku[web.1]: State changed from up to starting
2021-01-04T18:46:18.729190+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-01-04T18:46:18.801647+00:00 heroku[web.1]: Process exited with status 143
2021-01-04T18:46:53.555253+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:46:57.234794+00:00 app[web.1]:
2021-01-04T18:46:57.234819+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:46:57.234819+00:00 app[web.1]: > node server.js
2021-01-04T18:46:57.234820+00:00 app[web.1]:
2021-01-04T18:46:58.471423+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:46:58.471444+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:46:58.471446+00:00 app[web.1]: ^
2021-01-04T18:46:58.471446+00:00 app[web.1]:
2021-01-04T18:46:58.471447+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:46:58.471449+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:46:58.502509+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:46:58.503140+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:46:58.509321+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:46:58.509747+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:46:58.536286+00:00 app[web.1]:
2021-01-04T18:46:58.542292+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:46:58.542507+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_46_58_510Z-debug.log
2021-01-04T18:46:58.614100+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:46:58.673495+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:46:58.677305+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-04T18:47:24.050526+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:47:27.323089+00:00 app[web.1]:
2021-01-04T18:47:27.323103+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:47:27.323103+00:00 app[web.1]: > node server.js
2021-01-04T18:47:27.323104+00:00 app[web.1]:
2021-01-04T18:47:27.950882+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:47:27.950900+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:47:27.950901+00:00 app[web.1]: ^
2021-01-04T18:47:27.950903+00:00 app[web.1]:
2021-01-04T18:47:27.950903+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:47:27.950903+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:47:27.950905+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:47:27.970852+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:47:27.971425+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:47:27.976210+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:47:27.976596+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:47:27.987341+00:00 app[web.1]:
2021-01-04T18:47:27.987620+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:47:27.987792+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_47_27_977Z-debug.log
2021-01-04T18:47:28.067423+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:47:28.111585+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:48:09.000000+00:00 app[api]: Build started by user ishaqatfarah#gmail.com
2021-01-04T18:50:08.503349+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=41eadebc-6547-4735-975c-47f07af41139 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:13.899678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=f9c641f9-30c1-4ef7-a184-0d286cecf4c0 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:37.722683+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=a897151b-2c68-440d-bb39-877ad0e80b3c fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:38.328012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=3b546e46-3812-4a18-8f78-f585c9f3e740 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.226260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=df1690f0-5e59-4105-aae7-857d2a2ef8ff fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.682096+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=d4bee131-4929-4f80-96dd-d829a6c53bde fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https

Open Weather API Heroku worked fine on local system but crashes on Heroku

I am using open weather api. On my local system I used this request and it worked fine.
"http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit"
Then I searched solution for this problem online and modified the request as:
https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit
Honestky I dont know why we are using "https://cors-anywhere.herokuapp.com" .I would be glad if somebody explained the meaning.
I am still getting an error.Please help me.Thanks in advance.
herku log
Server started on port 3000
2020-08-10T11:40:06.567155+00:00 heroku[web.1]: State changed from starting to up
2020-08-10T11:40:10.839569+00:00 heroku[router]: at=info method=GET path="/" host=news-with-tea.herokuapp.com request_id=03988840-7db9-47b6-a22d-5aa10d525a59 fwd="49.205.248.228" dyno=web.1 connect=1ms service=653ms status=304 bytes=184 protocol=https
2020-08-10T11:40:11.865181+00:00 heroku[router]: at=info method=GET path="/css/styles.css" host=news-with-tea.herokuapp.com request_id=e4b7fc2c-55b4-41f8-82fe-37eb7f2bb710 fwd="49.205.248.228" dyno=web.1 connect=0ms service=6ms status=200 bytes=2033 protocol=https
2020-08-10T11:40:11.931225+00:00 heroku[router]: at=info method=GET path="/weather.js" host=news-with-tea.herokuapp.com request_id=6c6b0987-9f84-4ea7-b32d-563c0cee6596 fwd="49.205.248.228" dyno=web.1 connect=0ms service=10ms status=200 bytes=3968 protocol=https
2020-08-10T11:40:12.265807+00:00 heroku[router]: at=info method=GET path="/weather.js" host=news-with-tea.herokuapp.com request_id=f08b5be2-1c62-4f69-9193-1e32494490ab fwd="49.205.248.228" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2020-08-10T11:40:27.640043+00:00 app[web.1]: helllo[object Object]
2020-08-10T11:40:29.742161+00:00 app[web.1]: 17 78
2020-08-10T11:40:30.245240+00:00 app[web.1]: undefined:1
2020-08-10T11:40:30.245258+00:00 app[web.1]: Missing required request header. Must specify one of: origin,x-requested-with
2020-08-10T11:40:30.245258+00:00 app[web.1]: ^
2020-08-10T11:40:30.245258+00:00 app[web.1]:
2020-08-10T11:40:30.245259+00:00 app[web.1]: SyntaxError: Unexpected token M in JSON at position 0
2020-08-10T11:40:30.245260+00:00 app[web.1]: at JSON.parse (<anonymous>)
2020-08-10T11:40:30.245260+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/app.js:137:29)
2020-08-10T11:40:30.245261+00:00 app[web.1]: at IncomingMessage.emit (events.js:315:20)
2020-08-10T11:40:30.245261+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2020-08-10T11:40:30.245262+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:271:9)
2020-08-10T11:40:30.245262+00:00 app[web.1]: at IncomingMessage.Readable.push (_stream_readable.js:212:10)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at HTTPParser.parserOnBody (_http_common.js:132:24)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at TLSSocket.socketOnData (_http_client.js:469:22)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at TLSSocket.emit (events.js:315:20)
2020-08-10T11:40:30.245264+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2020-08-10T11:40:30.252437+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/weather" host=news-with-tea.herokuapp.com request_id=c9e29b82-7b67-4af0-9746-a118f77c69e7 fwd="49.205.248.228" dyno=web.1 connect=0ms service=511ms status=503 bytes=0 protocol=https
2020-08-10T11:40:30.252876+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/weather" host=news-with-tea.herokuapp.com request_id=a54e7548-a500-410a-8817-31e38dc20a2b fwd="49.205.248.228" dyno=web.1 connect=0ms service=2629ms status=503 bytes=0 protocol=https
2020-08-10T11:40:30.257162+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-10T11:40:30.257415+00:00 app[web.1]: npm ERR! errno 1
2020-08-10T11:40:30.259890+00:00 app[web.1]: npm ERR! ejs-challenge#1.0.0 start: `node app.js`
2020-08-10T11:40:30.260001+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-10T11:40:30.260127+00:00 app[web.1]: npm ERR!
2020-08-10T11:40:30.260237+00:00 app[web.1]: npm ERR! Failed at the ejs-challenge#1.0.0 start script.
2020-08-10T11:40:30.260419+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-10T11:40:30.271263+00:00 app[web.1]:
2020-08-10T11:40:30.271644+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-10T11:40:30.271681+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-10T11_40_30_261Z-debug.log
2020-08-10T11:40:30.361346+00:00 heroku[web.1]: Process exited with status 1
2020-08-10T11:40:30.404906+00:00 heroku[web.1]: State changed from up to crashed
2020-08-10T11:45:24.731721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=0b2f6496-cba4-40ea-94b1-d4de70aab61a fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:45:24.969535+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=5f1db2b1-b242-4c8c-9541-4cf19dd486ed fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:45:29.819254+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=3a5fed80-b456-452e-86bc-b47dd644f2b6 fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:48:09.750615+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-10T11:48:12.239984+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-10T11:48:14.253874+00:00 app[web.1]:
2020-08-10T11:48:14.253897+00:00 app[web.1]: > ejs-challenge#1.0.0 start /app
2020-08-10T11:48:14.253898+00:00 app[web.1]: > node app.js
2020-08-10T11:48:14.253898+00:00 app[web.1]:
2020-08-10T11:48:14.441205+00:00 app[web.1]: Server started on port 3000
2020-08-10T11:48:14.541655+00:00 heroku[web.1]: State changed from starting to up
app.get('/weather',function(req,res){
const unit="metric";
const url="https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit;
https.get(url,function(response){
response.on("data",function(data){
// convert data into JSON object
const weatherData= JSON.parse(data);
console.log(weatherData);
const id=weatherData.weather[0].id;
res.render('weather',{weatherData:weatherData,id:id});
})
})
});
You don't need to use "https://cors-anywhere.herokuapp.com/", the API doesn't differentiate between your local request or a request coming from an heroku server.

Mern app working locally - 503 error on Heroku (H10-H13)

I have made a project through a course with Brad Traversy called contact keeper. It works fine locally on my machine and I get contact with the database.
Once I push it to Heroku I cant log in or register anymore. I get a 503 error (H10 & H13 errors from heroku) saying service unavailable when trying to hit those endpoints.
I have tried looking on similar threads but it does not work for me. I have added a procfile and checked through my package.json and it looks alright (from what I see).
The full repository can be found here: https://github.com/Dannus90/Contact_Keeper_MERN
const express = require('express');
const connectDB = require('./config/db');
const path = require('path');
const app = express();
// Connect Database
connectDB();
// Init Middleware
app.use(express.json({ extended: false }));
// Define Routes
app.use('/api/users', require('./routes/users'));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/contacts', require('./routes/contacts'));
// Serve static assets in production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) =>
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
);
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
In the picture below you can see where it fails. It is in the AuthState file when it tries to hit the endpoints.
The complete error log from heroku can be seen below:
2020-05-17T09:23:20.616623+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:23:50.230066+00:00 app[web.1]: connection <monitor> to 52.31.65.44:27017 closed
2020-05-17T09:23:50.240114+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:23:50.240313+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:23:50.241253+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:23:50.241374+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:23:50.241498+00:00 app[web.1]: npm ERR!
2020-05-17T09:23:50.241622+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:23:50.241760+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:23:50.249534+00:00 app[web.1]:
2020-05-17T09:23:50.249723+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:23:50.249843+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_23_50_242Z-debug.log
2020-05-17T09:23:50.311445+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:26:49.000000+00:00 app[api]: Build started by user persson.daniel.1990#gmail.com
2020-05-17T09:28:20.734327+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:28:20.461350+00:00 app[api]: Release v48 created by user persson.daniel.1990#gmail.com
2020-05-17T09:28:20.461350+00:00 app[api]: Deploy 502ce232 by user persson.daniel.1990#gmail.com
2020-05-17T09:28:21.000000+00:00 app[api]: Build succeeded
2020-05-17T09:28:30.543747+00:00 app[web.1]:
2020-05-17T09:28:30.543761+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:28:30.543761+00:00 app[web.1]: > node server.js
2020-05-17T09:28:30.543762+00:00 app[web.1]:
2020-05-17T09:28:31.157953+00:00 app[web.1]: Server started on port 13966
2020-05-17T09:28:32.044290+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:28:33.217189+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=ed1492f5-d053-4ecf-8a88-8561992f3403 fwd="78.82.2.105" dyno=web.1 connect=0ms service=11ms status=200 bytes=2626 protocol=https
2020-05-17T09:28:33.348570+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css" host=afternoon-earth-34040.herokuapp.com request_id=410da44d-797f-4a41-bafe-f130118e8c6d fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=4578 protocol=https
2020-05-17T09:28:33.346039+00:00 heroku[router]: at=info method=GET path="/static/js/main.6e77bd50.chunk.js" host=afternoon-earth-34040.herokuapp.com request_id=018e556e-91d6-4944-bd6e-0c5b74ece68a fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=28978 protocol=https
2020-05-17T09:28:33.474881+00:00 heroku[router]: at=info method=GET path="/static/js/2.9c49eab7.chunk.js" host=afternoon-earth-34040.herokuapp.com request_id=5379490e-fd9b-47c1-b001-15e036784e2d fwd="78.82.2.105" dyno=web.1 connect=0ms service=10ms status=200 bytes=192222 protocol=https
2020-05-17T09:28:33.992494+00:00 heroku[router]: at=info method=GET path="/api/contacts" host=afternoon-earth-34040.herokuapp.com request_id=3684bbba-83b1-4d90-b9f8-d4ba7dedbc60 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=401 bytes=257 protocol=https
2020-05-17T09:28:33.990977+00:00 heroku[router]: at=info method=GET path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=705c0086-3927-4e6f-b2dd-45ac9165e303 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=401 bytes=257 protocol=https
2020-05-17T09:28:34.365542+00:00 heroku[router]: at=info method=GET path="/manifest.json" host=afternoon-earth-34040.herokuapp.com request_id=1f38b786-2c3d-411e-8aee-6862c40e77d4 fwd="78.82.2.105" dyno=web.1 connect=1ms service=6ms status=200 bytes=787 protocol=https
2020-05-17T09:28:34.483877+00:00 heroku[router]: at=info method=GET path="/logo192.png" host=afternoon-earth-34040.herokuapp.com request_id=65807958-8954-4332-8cab-dc4320e2cac8 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=200 bytes=5622 protocol=https
2020-05-17T09:28:42.084546+00:00 heroku[router]: at=info method=GET path="/static/js/2.9c49eab7.chunk.js.map" host=afternoon-earth-34040.herokuapp.com request_id=d186f408-b227-4ce3-8f6d-2858c2b6b5a0 fwd="78.82.2.105" dyno=web.1 connect=0ms service=18ms status=200 bytes=624338 protocol=https
2020-05-17T09:28:42.056584+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css" host=afternoon-earth-34040.herokuapp.com request_id=4ebde32e-fca4-4968-89d2-e10af56e5ad3 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=304 bytes=238 protocol=https
2020-05-17T09:28:42.176331+00:00 heroku[router]: at=info method=GET path="/static/js/main.6e77bd50.chunk.js.map" host=afternoon-earth-34040.herokuapp.com request_id=22d537d1-9c6e-445b-985a-78f2319dd192 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=61221 protocol=https
2020-05-17T09:28:42.289347+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css.map" host=afternoon-earth-34040.herokuapp.com request_id=7418f08d-9c43-47e0-b2d3-2f2d23652356 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=200 bytes=15892 protocol=https
2020-05-17T09:29:01.254923+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=82f5a82c-e065-4e9e-a284-a82ba86287d2 fwd="78.82.2.105" dyno=web.1 connect=0ms service=15877ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.362981+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:29:01.235846+00:00 app[web.1]: connection <monitor> to 54.72.107.147:27017 closed
2020-05-17T09:29:01.262738+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:29:01.263049+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:29:01.263998+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:29:01.264159+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:29:01.264337+00:00 app[web.1]: npm ERR!
2020-05-17T09:29:01.264484+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:29:01.264618+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:29:01.270789+00:00 app[web.1]:
2020-05-17T09:29:01.270997+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:29:01.271145+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_29_01_265Z-debug.log
2020-05-17T09:29:01.256625+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=0e0e84a4-257b-43bd-a31d-b97ebaed5a10 fwd="78.82.2.105" dyno=web.1 connect=0ms service=16031ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.256627+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=acbb4fdf-bf07-4668-886e-a253a3e0aee3 fwd="78.82.2.105" dyno=web.1 connect=0ms service=15442ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.257557+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=1a45a04e-0c1e-47ea-b796-7299db72f732 fwd="78.82.2.105" dyno=web.1 connect=0ms service=21480ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.257996+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=2531aa80-5bf8-42e8-b620-ff9f2969ba1f fwd="78.82.2.105" dyno=web.1 connect=0ms service=15579ms status=503 bytes=0 protocol=https
2020-05-17T09:29:04.000000+00:00 app[api]: Build started by user persson.daniel.1990#gmail.com
2020-05-17T09:30:32.857023+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:30:32.560586+00:00 app[api]: Release v49 created by user persson.daniel.1990#gmail.com
2020-05-17T09:30:32.560586+00:00 app[api]: Deploy aba0d37e by user persson.daniel.1990#gmail.com
2020-05-17T09:30:34.000000+00:00 app[api]: Build succeeded
2020-05-17T09:30:44.786119+00:00 app[web.1]:
2020-05-17T09:30:44.786136+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:30:44.786137+00:00 app[web.1]: > node server.js
2020-05-17T09:30:44.786137+00:00 app[web.1]:
2020-05-17T09:30:45.574040+00:00 app[web.1]: Server started on port 52681
2020-05-17T09:30:46.081535+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:31:15.677435+00:00 app[web.1]: connection <monitor> to 52.31.65.44:27017 closed
2020-05-17T09:31:15.698356+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:31:15.698666+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:31:15.699733+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:31:15.699922+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:31:15.700135+00:00 app[web.1]: npm ERR!
2020-05-17T09:31:15.700312+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:31:15.700467+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:31:15.723946+00:00 app[web.1]:
2020-05-17T09:31:15.724237+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:31:15.724392+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_31_15_704Z-debug.log
2020-05-17T09:31:15.828237+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:35:10.524783+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:35:21.345206+00:00 app[web.1]:
2020-05-17T09:35:21.345238+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:35:21.345238+00:00 app[web.1]: > node server.js
2020-05-17T09:35:21.345239+00:00 app[web.1]:
2020-05-17T09:35:22.181653+00:00 app[web.1]: Server started on port 57715
2020-05-17T09:35:22.526258+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:35:52.241989+00:00 app[web.1]: connection <monitor> to 54.72.107.147:27017 closed
2020-05-17T09:35:52.255501+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:35:52.256048+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:35:52.257707+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:35:52.258009+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:35:52.258313+00:00 app[web.1]: npm ERR!
2020-05-17T09:35:52.258505+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:35:52.258686+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:35:52.266384+00:00 app[web.1]:
2020-05-17T09:35:52.266689+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:35:52.266864+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_35_52_259Z-debug.log
2020-05-17T09:35:52.425747+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:37:40.075229+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=b86ff65a-3c2f-4609-85ba-a75500f93e3a fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:40.189972+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=d5b50b56-a5df-4d19-9c0f-6298c0dea421 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:42.254860+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=afternoon-earth-34040.herokuapp.com request_id=20cdf3b9-5883-4dcd-898a-03eb6ee20dc5 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:43.970046+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=afternoon-earth-34040.herokuapp.com request_id=dc0e7da8-46fa-4da1-bdb6-4814157e43a5 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:44.242232+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-earth-34040.herokuapp.com request_id=53adb339-25bb-4bca-9b89-638035820973 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
This is the code from my db file:
const mongoose = require("mongoose");
const config = require("config");
const db = config.get("mongoURI");
const connectDB = async () => {
try {
await mongoose.connect(db, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
});
console.log("MongoDB Connected");
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;
This is the database (found in default and production.js):
{
"mongoURI": "mongodb+srv://Daniel123:Daniel123#contactkeeper-rjjr4.mongodb.net/test?retryWrites=true&w=majority",
"jwtSecret": "secret"
}
Solution for me for this problem (incase anyone else get the problem):
I whitelisted 0.0.0.0/0 on mongodb, set environmental variables on heroku and set them as an alternative for the db connect(same with jwtSecret in the config), since the config was ignored when pushing to heroku:
const mongoose = require("mongoose");
const config = require("config");
const db = config.get("mongoURI");
const connectDB = async () => {
try {
await mongoose.connect(db || process.env.mongoURI, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
});
console.log("MongoDB Connected");
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;

Application Error for deploying Node.js app to Heroku

I am new to deploying Github projects to Heroku. So far, I have connected my app to Heroku successfully and have deployed. The project runs fine on my local machine. However, when I tried to launch the heroku website of my app, it gave me this error:
"An error occurred in the application and your page could not be
served. Please try again in a few moments.
If you are the application owner, check your logs for details."
Here is my heroku log, which I am having trouble understanding.
2015-11-10T04:33:10.538175+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=af3a9061-1b8f-47fe-9e2e-eafa624f2712 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:10.649481+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=e8fc1b43-f629-4e38-85c9-808d731e852e fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:11.334843+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=149ffc6c-8a57-475c-9f64-5224bcf72bfd fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:12.207897+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=4585d320-5d3b-43a0-ab85-a84f9734e373 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:18.757410+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=1d59ddd7-ff62-4b01-8b3a-df450fac5ba5 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:19.737947+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=2f8f9bc8-8299-4da9-bdad-eed9fa537573 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:19.503853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=77870378-cde5-48e2-b4d2-e93526b1e10d fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:41:09.087924+00:00 heroku[api]: Deploy 5c325e8 by myemail#gmail.com
2015-11-10T04:41:09.087924+00:00 heroku[api]: Release v6 created by myemail#gmail.com
2015-11-10T04:41:09.271289+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:41:09.271300+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:41:11.469002+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:41:12.469938+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:41:14.322786+00:00 app[web.1]: module.js:339
2015-11-10T04:41:14.322794+00:00 app[web.1]: throw err;
2015-11-10T04:41:14.322795+00:00 app[web.1]: ^
2015-11-10T04:41:14.322796+00:00 app[web.1]:
2015-11-10T04:41:14.322797+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:41:14.322797+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:41:14.322798+00:00 app[web.1]: at Function.Module._load (module.js:287:25)
2015-11-10T04:41:14.322799+00:00 app[web.1]: at Module.require (module.js:366:17)
2015-11-10T04:41:14.322799+00:00 app[web.1]: at require (module.js:385:17)
2015-11-10T04:41:14.322800+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:41:14.322800+00:00 app[web.1]: at Module._compile (module.js:425:26)
2015-11-10T04:41:14.322801+00:00 app[web.1]: at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:41:14.322802+00:00 app[web.1]: at Module.load (module.js:356:32)
2015-11-10T04:41:14.322802+00:00 app[web.1]: at Function.Module._load (module.js:311:12)
2015-11-10T04:41:14.322803+00:00 app[web.1]: at Function.Module.runMain (module.js:457:10)
2015-11-10T04:41:15.124877+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:41:15.116760+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:44:48.813133+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=81fddfea-92e6-4c64-91aa-ec5d076fb8e6 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:44:49.590449+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=efa1b5fc-5a1e-4b31-acef-5a1025e8c99d fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:44:49.955648+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=4af0cf53-ea53-4361-a5d2-6a3efc51a62f fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:51:46.883632+00:00 heroku[api]: Deploy b0f6afe by myemail#gmail.com
2015-11-10T04:51:46.883703+00:00 heroku[api]: Release v7 created by myemail#gmail.com
2015-11-10T04:51:46.979243+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:51:47.041376+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:51:47.041386+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:51:48.436794+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:51:50.436732+00:00 app[web.1]: module.js:339
2015-11-10T04:51:50.436759+00:00 app[web.1]: at Function.Module._load (module.js:287:25)
2015-11-10T04:51:50.436761+00:00 app[web.1]: at Module._compile (module.js:425:26)
2015-11-10T04:51:50.436754+00:00 app[web.1]: throw err;
2015-11-10T04:51:50.436756+00:00 app[web.1]:
2015-11-10T04:51:50.436763+00:00 app[web.1]: at Function.Module._load (module.js:311:12)
2015-11-10T04:51:50.436755+00:00 app[web.1]: ^
2015-11-10T04:51:50.436759+00:00 app[web.1]: at Module.require (module.js:366:17)
2015-11-10T04:51:50.436757+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:51:50.436758+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:51:50.436762+00:00 app[web.1]: at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:51:50.436764+00:00 app[web.1]: at Function.Module.runMain (module.js:457:10)
2015-11-10T04:51:50.436760+00:00 app[web.1]: at require (module.js:385:17)
2015-11-10T04:51:50.436760+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:51:50.436762+00:00 app[web.1]: at Module.load (module.js:356:32)
2015-11-10T04:51:51.157210+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:51:52.735586+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:51:55.545983+00:00 app[web.1]: module.js:339
2015-11-10T04:51:55.545998+00:00 app[web.1]: throw err;
2015-11-10T04:51:55.545999+00:00 app[web.1]: ^
2015-11-10T04:51:55.545999+00:00 app[web.1]:
2015-11-10T04:51:55.546001+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:51:55.546002+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:51:55.546002+00:00 app[web.1]: at Function.Module._load (module.js:287:25)
2015-11-10T04:51:55.546003+00:00 app[web.1]: at Module.require (module.js:366:17)
2015-11-10T04:51:55.546003+00:00 app[web.1]: at require (module.js:385:17)
2015-11-10T04:51:55.546004+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:51:55.546004+00:00 app[web.1]: at Module._compile (module.js:425:26)
2015-11-10T04:51:55.546005+00:00 app[web.1]: at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:51:55.546006+00:00 app[web.1]: at Module.load (module.js:356:32)
2015-11-10T04:51:55.546007+00:00 app[web.1]: at Function.Module.runMain (module.js:457:10)
2015-11-10T04:51:55.546006+00:00 app[web.1]: at Function.Module._load (module.js:311:12)
2015-11-10T04:51:51.172084+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:51:51.173050+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:51:56.492216+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:51:56.506380+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:53:27.766915+00:00 heroku[api]: Deploy 15c64ba by myemail#gmail.com
2015-11-10T04:53:27.766915+00:00 heroku[api]: Release v8 created by myemail#gmail.com
2015-11-10T04:53:27.910792+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:53:27.910801+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:53:27.921730+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:53:29.221014+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:53:31.264123+00:00 app[web.1]: module.js:339
2015-11-10T04:53:31.264132+00:00 app[web.1]: throw err;
2015-11-10T04:53:31.264133+00:00 app[web.1]: ^
2015-11-10T04:53:31.264134+00:00 app[web.1]:
2015-11-10T04:53:31.264135+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:53:31.264136+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:53:31.264136+00:00 app[web.1]: at Function.Module._load (module.js:287:25)
2015-11-10T04:53:31.264137+00:00 app[web.1]: at Module.require (module.js:366:17)
2015-11-10T04:53:31.264138+00:00 app[web.1]: at require (module.js:385:17)
2015-11-10T04:53:31.264138+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:53:31.264139+00:00 app[web.1]: at Module._compile (module.js:425:26)
2015-11-10T04:53:31.264140+00:00 app[web.1]: at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:53:31.264140+00:00 app[web.1]: at Module.load (module.js:356:32)
2015-11-10T04:53:31.264141+00:00 app[web.1]: at Function.Module._load (module.js:311:12)
2015-11-10T04:53:31.264141+00:00 app[web.1]: at Function.Module.runMain (module.js:457:10)
2015-11-10T04:53:31.969583+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:53:31.989169+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:54:44.812224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=a508a64d-8a85-4d09-a610-67ef57854186 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:54:45.733283+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=1a312b38-8793-41fa-9a77-2d2e7f0c63f2 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:54:45.461863+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=47d48dc9-3e16-4b49-8b25-7b56a8b3ccad fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
I'm thinking the error might be due to how I'm setting up my routes. Here is my app.js, where I specify my routes:
var express = require('express');
var app = express();
var http = require('http').Server(app);
// set up handlebars view engine
var handlebars = require('express3-handlebars')
.create({ defaultLayout:'main' });
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
http.listen(process.env.PORT || 3000, function(){
console.log('listening on', http.address().port);
})
// Home Page
app.get('/', function(req, res){
res.render('home');
});
// About Page
app.get('/about', function(req, res){
res.render('about');
});
// 404 catch-all handler (middleware)
app.use(function(req, res){
res.status(404);
res.render('404');
});
// 500 error handler (middleware)
app.use(function(req, res){
console.error(err.stack);
res.status(500);
res.render('500');
});
app.listen(app.get('port'), function(){
console.log( 'Express started on http://localhost:' +
app.get('port') + '; press Ctrl-C to terminate.' );
});
Here is my package.json:
{
"name": "Compass",
"version": "1.0.0",
"description": "Independent Study Application",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "Thao Bach",
"license": "ISC",
"dependencies": {
"express": "^4.13.3",
"express-handlebars": "^2.0.1",
"mongodb": "^2.0.46",
"monk": "^1.0.1"
},
"devDependencies": {
"archiver": "^0.15.1",
"chai": "^3.3.0",
"fs-extra": "^0.24.0",
"mocha": "^2.3.3"
}
}
Most likely you do not have npm dependency express3-handlebars mentioned in your package.json or else it is mentioned as development Dependency in your package.json file.
Also, in your app.js you are using
var handlebars = require('express3-handlebars')
.create({ defaultLayout:'main' });
you may want to change your require statement to point to express-handlebars or else include express3-handlebars as dependency

Resources