I am deploying a fullstack react/express app to Heroku, it has managed to deploy. There are multiple errors in the Heroku logs which I have cannot seem to understand/figure out. I also have a Procfile with web: node server.js
I have tried to clear cache - delete node_modules and package.json then npm install again but this has not made a difference.
Heroku Logs
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:12.783289+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:12.818062+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:08:12.826070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:08:21.448256+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-11-15T13:08:24.324135+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:08:24.324170+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:08:24.324175+00:00 app[web.1]: ^
2020-11-15T13:08:24.324175+00:00 app[web.1]:
2020-11-15T13:08:24.324180+00:00 app[web.1]: 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.
2020-11-15T13:08:24.324185+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:08:24.324185+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:08:24.324190+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:24.324192+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:24.324196+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:24.418110+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:24.454083+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:23:24.786742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-journey-43421.herokuapp.com request_id=aa6c54d3-cfe3-4f74-b4c5-93018f00ba97 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:23:26.240301+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-journey-43421.herokuapp.com request_id=ec07ad1c-091f-4e53-b50d-9632b66dd2d4 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:27:28.000000+00:00 app[api]: Build started by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Deploy 12d81f3b by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Release v12 created by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.625747+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:09.000000+00:00 app[api]: Build succeeded
2020-11-15T13:29:17.927953+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:20.083139+00:00 app[web.1]:
2020-11-15T13:29:20.083155+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:20.083155+00:00 app[web.1]: > node server.js
2020-11-15T13:29:20.083155+00:00 app[web.1]:
2020-11-15T13:29:20.795200+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:20.795248+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:20.795250+00:00 app[web.1]: ^
2020-11-15T13:29:20.795250+00:00 app[web.1]:
2020-11-15T13:29:20.795251+00:00 app[web.1]: 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.
2020-11-15T13:29:20.795252+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:20.795254+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:20.795254+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:20.795257+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:20.795258+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:20.810114+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:20.810451+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:20.817598+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: `node server.js`
2020-11-15T13:29:20.817850+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:20.818099+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:20.818312+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:20.818490+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:20.827750+00:00 app[web.1]:
2020-11-15T13:29:20.828041+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:20.828210+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_20_819Z-debug.log
2020-11-15T13:29:20.877545+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:20.913439+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:29:20.917070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:33.460653+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:36.844587+00:00 app[web.1]:
2020-11-15T13:29:36.844630+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:36.844631+00:00 app[web.1]: > node server.js
2020-11-15T13:29:36.844631+00:00 app[web.1]:
2020-11-15T13:29:38.011159+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:38.011219+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:38.011220+00:00 app[web.1]: ^
2020-11-15T13:29:38.011220+00:00 app[web.1]:
2020-11-15T13:29:38.011224+00:00 app[web.1]: 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.
2020-11-15T13:29:38.011224+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:38.011225+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:38.011226+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:38.011229+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:38.046555+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:38.047758+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:38.059446+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: node server.js
2020-11-15T13:29:38.059681+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:38.059955+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:38.060192+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:38.060432+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:38.096793+00:00 app[web.1]:
2020-11-15T13:29:38.097273+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:38.097587+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_38_061Z-debug.log
2020-11-15T13:29:38.193702+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:38.242866+00:00 heroku[web.1]: State changed from starting to crashed
Server.js
const express = require('express');
const app = express();
const path = require('path');
const cors = require('cors');
const port = process.env.PORT || 5000;
const dotenv = require('dotenv');
const mongoose = require('mongoose');
// Auth Routes
const authRoute = require('./routes/auth');
dotenv.config();
//Connect to DB
mongoose.connect(process.env.DB_CONNECT,
{ useNewUrlParser: true, useUnifiedTopology: true },
() => console.log('connected to DB!')
);
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build/')));
// Middleware
app.use(express.json());
app.use(cors());
// Put all API endpoints under '/api'
app.use('/api', authRoute)
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/build/index.html'));
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
Package.json
{
"name": "movie-database",
"version": "1.0.0",
"description": "Small application created with React.js, react router and the movie database to showcase all latest, upcoming and most popular movies.",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"joi": "^17.3.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"mongoose": "^5.10.12",
"nodemon": "^2.0.6",
"password-generator": "^2.3.2",
"serve": "^11.3.2"
}
}
I cannot figure out what is going wrong?
Related
My app works locally, but when trying to deploy I get code=H10. I have tried looking up code=H10 failures, but they all see to lead to changes with process.env.PORT changes, which I have already done in various ways.
This is my first time deploying to heroku, so sorry if I am missing some important information.
Any advice will be much appreciated.
My logs:
2021-05-16T23:27:11.291289+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:27:11.291289+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:27:11.291289+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:27:11.291290+00:00 app[web.1]: requireStack: []
2021-05-16T23:27:11.291290+00:00 app[web.1]: }
2021-05-16T23:27:11.341722+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:27:11.432934+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:27:55.798013+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=3428bce1-739d-47ed-9205-9859475e0e22 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:33:49.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Release v17 created by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Deploy 31855de1 by user joshuamacleod#live.com
2021-05-16T23:36:06.264449+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:36:07.000000+00:00 app[api]: Build succeeded
2021-05-16T23:36:19.886178+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:36:22.175404+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:36:22.175424+00:00 app[web.1]: throw err;
2021-05-16T23:36:22.175425+00:00 app[web.1]: ^
2021-05-16T23:36:22.175425+00:00 app[web.1]:
2021-05-16T23:36:22.175426+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:36:22.175426+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:36:22.175428+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:36:22.175428+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:36:22.175429+00:00 app[web.1]: requireStack: []
2021-05-16T23:36:22.175429+00:00 app[web.1]: }
2021-05-16T23:36:22.240102+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:36:22.322859+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:36:50.313742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=0e8e0047-c98d-4126-9008-c50c7d927320 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:43:04.802415+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:43:19.981689+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:43:22.004092+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:43:22.004127+00:00 app[web.1]: throw err;
2021-05-16T23:43:22.004127+00:00 app[web.1]: ^
2021-05-16T23:43:22.004128+00:00 app[web.1]:
2021-05-16T23:43:22.004128+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:43:22.004130+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:43:22.004131+00:00 app[web.1]: requireStack: []
2021-05-16T23:43:22.004131+00:00 app[web.1]: }
2021-05-16T23:43:22.064674+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:43:22.121461+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:56:01.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Release v18 created by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Deploy 09023d82 by user joshuamacleod#live.com
2021-05-16T23:58:17.959761+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:19.000000+00:00 app[api]: Build succeeded
2021-05-16T23:58:35.537730+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:38.809616+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:38.809639+00:00 app[web.1]: throw err;
2021-05-16T23:58:38.809640+00:00 app[web.1]: ^
2021-05-16T23:58:38.809640+00:00 app[web.1]:
2021-05-16T23:58:38.809640+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:38.809641+00:00 app[web.1]: Require stack:
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:38.809642+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:38.809646+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:38.809646+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:38.809648+00:00 app[web.1]: }
2021-05-16T23:58:38.902832+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:38.974809+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:58:38.986788+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:50.650040+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:52.992272+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:52.992286+00:00 app[web.1]: throw err;
2021-05-16T23:58:52.992286+00:00 app[web.1]: ^
2021-05-16T23:58:52.992286+00:00 app[web.1]:
2021-05-16T23:58:52.992287+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:52.992287+00:00 app[web.1]: Require stack:
2021-05-16T23:58:52.992287+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:52.992294+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:52.992294+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:52.992294+00:00 app[web.1]: }
2021-05-16T23:58:53.061937+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:53.120732+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:59:37.345240+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=76cb051f-7ecc-451e-93cc-50f56beac59a fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
My server:
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const passport = require("passport");
const users = require("./routes/api/users");
const path = require("path");
const db = require('./db')
const articleRouter = require('./routes/article-router')
const app = express()
const server = process.env.PORT || 5000
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(cors())
app.use(bodyParser.json())
app.use(passport.initialize());
app.use(express.static(path.join(__dirname, "client", "build")))
require("./config/passport")(passport);
db.on('error', console.error.bind(console, 'MongoDB connection error:'))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
app.use('/api', articleRouter)
app.use("/api/users", users);
app.listen(server, () => console.log(`Server running on port ${server}`))
My package.json:
{
"name": "news-server",
"version": "1.0.0",
"engines": {
"node": ">= 14.15.5",
"npm": "6.14.11"
},
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd news-front && npm install --only=dev && npm install && npm run build"
}
My Procfile:
web: node server.js
A Procfile is not always necessary to deploy Node.js apps to Heroku, however, your package.json is very very important. The package.json file should include the modules to be installed. Which is missing.
The logs clearly say code: 'MODULE_NOT_FOUND', which means node_modules/ are missing.
You might have node_modules/ in your local system, but Heroku ignores it. It takes package.json and freshly starts to download it.
Heroku runs something like this. It Deletes node_modules/ then runs "npm install" then "node server.js"
For you, I would advice to always save your node_modules/ to package.json. This can be done while installing modules easily by adding --save
To debug this, do
"npm install --save express cors passport"
You can do this or do
"npm i --save express"
"npm i --save cors"
"npm i --save passport"
It is then showing me ./routes/api/users - I hope you have it.
I'm trying to upload my first node.js application to heroku. Build is showing successful, but the application cannot be opened in browser. Here is the logs tail of the deployment. I'm not quite sure where the problem(s) lie(s). All localhost routes are actually working when tested with postman. I'm using express generator, so the PORT is declared in .bin/www. I'm also using .env. I'm a bit lost about where to look next. Any suggestions? Many thanks!
2021-01-11T22:10:14.214188+00:00 app[web.1]: > finale-backend#0.0.0 start /app
2021-01-11T22:10:14.214189+00:00 app[web.1]: > node ./bin/www
2021-01-11T22:10:14.214189+00:00 app[web.1]:
2021-01-11T22:10:14.285451+00:00 app[web.1]: internal/modules/cjs/loader.js:818
2021-01-11T22:10:14.285453+00:00 app[web.1]: throw err;
2021-01-11T22:10:14.285453+00:00 app[web.1]: ^
2021-01-11T22:10:14.285454+00:00 app[web.1]:
2021-01-11T22:10:14.285454+00:00 app[web.1]: Error: Cannot find module 'dotenv'
2021-01-11T22:10:14.285454+00:00 app[web.1]: Require stack:
2021-01-11T22:10:14.285455+00:00 app[web.1]: - /app/app.js
2021-01-11T22:10:14.285455+00:00 app[web.1]: - /app/bin/www
2021-01-11T22:10:14.285456+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
2021-01-11T22:10:14.285456+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:667:27)
2021-01-11T22:10:14.285457+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-11T22:10:14.285457+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2021-01-11T22:10:14.285458+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:1:1)
2021-01-11T22:10:14.285458+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-11T22:10:14.285459+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-11T22:10:14.285459+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-11T22:10:14.285459+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-11T22:10:14.285460+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19) {
2021-01-11T22:10:14.285460+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-01-11T22:10:14.285461+00:00 app[web.1]: requireStack: [ '/app/app.js', '/app/bin/www' ]
2021-01-11T22:10:14.285461+00:00 app[web.1]: }
2021-01-11T22:10:14.301983+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-01-11T22:10:14.302357+00:00 app[web.1]: npm ERR! errno 1
2021-01-11T22:10:14.309690+00:00 app[web.1]: npm ERR! finale-backend#0.0.0 start: `node ./bin/www`
2021-01-11T22:10:14.309804+00:00 app[web.1]: npm ERR! Exit status 1
2021-01-11T22:10:14.309965+00:00 app[web.1]: npm ERR!
2021-01-11T22:10:14.310034+00:00 app[web.1]: npm ERR! Failed at the finale-backend#0.0.0 start script.
2021-01-11T22:10:14.310119+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-01-11T22:10:14.317026+00:00 app[web.1]:
2021-01-11T22:10:14.317243+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-11T22:10:14.317339+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-11T22_10_14_310Z-debug.log
2021-01-11T22:10:14.361923+00:00 heroku[web.1]: Process exited with status 1
2021-01-11T22:10:14.435764+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-11T22:10:14.439118+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-11T22:10:16.805923+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-11T22:10:19.751944+00:00 app[web.1]:
2021-01-11T22:10:19.751961+00:00 app[web.1]: > finale-backend#0.0.0 start /app
2021-01-11T22:10:19.751962+00:00 app[web.1]: > node ./bin/www
2021-01-11T22:10:19.751963+00:00 app[web.1]:
2021-01-11T22:10:19.808881+00:00 app[web.1]: internal/modules/cjs/loader.js:818
2021-01-11T22:10:19.808883+00:00 app[web.1]: throw err;
2021-01-11T22:10:19.808883+00:00 app[web.1]: ^
2021-01-11T22:10:19.808883+00:00 app[web.1]:
2021-01-11T22:10:19.808884+00:00 app[web.1]: Error: Cannot find module 'dotenv'
2021-01-11T22:10:19.808884+00:00 app[web.1]: Require stack:
2021-01-11T22:10:19.808884+00:00 app[web.1]: - /app/app.js
2021-01-11T22:10:19.808885+00:00 app[web.1]: - /app/bin/www
2021-01-11T22:10:19.808885+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
2021-01-11T22:10:19.808885+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:667:27)
2021-01-11T22:10:19.808886+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-11T22:10:19.808886+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2021-01-11T22:10:19.808887+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:1:1)
2021-01-11T22:10:19.808887+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-11T22:10:19.808887+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-11T22:10:19.808888+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-11T22:10:19.808888+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-11T22:10:19.808889+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19) {
2021-01-11T22:10:19.808889+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-01-11T22:10:19.808889+00:00 app[web.1]: requireStack: [ '/app/app.js', '/app/bin/www' ]
2021-01-11T22:10:19.808890+00:00 app[web.1]: }
2021-01-11T22:10:19.834122+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-01-11T22:10:19.834754+00:00 app[web.1]: npm ERR! errno 1
2021-01-11T22:10:19.843644+00:00 app[web.1]: npm ERR! finale-backend#0.0.0 start: `node ./bin/www`
2021-01-11T22:10:19.843996+00:00 app[web.1]: npm ERR! Exit status 1
2021-01-11T22:10:19.844353+00:00 app[web.1]: npm ERR!
2021-01-11T22:10:19.844619+00:00 app[web.1]: npm ERR! Failed at the finale-backend#0.0.0 start script.
2021-01-11T22:10:19.844914+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-01-11T22:10:19.858827+00:00 app[web.1]:
2021-01-11T22:10:19.859298+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-11T22:10:19.859536+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-11T22_10_19_845Z-debug.log
2021-01-11T22:10:19.946324+00:00 heroku[web.1]: Process exited with status 1
2021-01-11T22:10:20.030800+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-11T22:10:22.579029+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=XXXXXX.herokuapp.com request_id=28ed0f16-48b7-4edb-a4d4-bf5af57518a5 fwd="91.106.154.160" dyno= connect= service= status=503 bytes= protocol=https
2021-01-11T22:10:23.309377+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=XXXXXX.herokuapp.com request_id=967010fc-984e-49c7-a73e-9d9758907f49 fwd="91.106.154.160" dyno= connect= service= status=503 bytes= protocol=https
My package json looks like this:
{
"name": "finale-backend",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www"
},
"dependencies": {
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"debug": "~2.6.9",
"express": "~4.16.1",
"helmet": "^4.3.1",
"jsonwebtoken": "^8.5.1",
"logger": "0.0.1",
"morgan": "~1.9.1",
"nodemon": "^2.0.7",
"pg": "^8.5.1"
},
"devDependencies": {
"dotenv": "^8.2.0"
},
"engines": {
"node": "12.x"
}
}
And I require dotenv in my entry point app.js like this
require('dotenv').config();
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const cors = require('cors')
It seems like Heroku is not installing devDependencies by default. You may want to move dotenv to dependencies in your package.json and try again.
If you don't need dotenv in your production environment, you may want to remove the require altogether and use a different command to run your development server, as described here:
https://www.npmjs.com/package/dotenv#preload
node -r dotenv/config your_script.js
This will prevent your server from crashing in production when the dotenv dependency is not found on Heroku.
The reason because you are using dotenv in devDependencies. Change dotenv dependency to dependencies like this:
"dependencies": {
...,
"dotenv": "^8.2.0"
}
i'm deploying my first app on heroku, i pushed the code on GitHub, add Heroku keys(because ), created the heroku app on terminal and finally git push heroku master.
The app is very basic, but it doesn't work, and i can't even find a decent log information to work with!
This is the long log that i found.
Hope someone could help me!
2019-12-06T00:11:00.862870+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:11:00.862872+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:11:00.862874+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:11:00.862876+00:00 app[web.1]: }
2019-12-06T00:11:00.870032+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:11:00.871330+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:11:00.871733+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:11:00.872684+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:11:00.872690+00:00 app[web.1]: npm ERR!
2019-12-06T00:11:00.872695+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:11:00.872698+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:11:02.538864+00:00 app[web.1]:
2019-12-06T00:11:02.542433+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:11:02.542703+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_11_00_875Z-debug.log
2019-12-06T00:11:02.625046+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:11:02.614891+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:18:05.000000+00:00 app[api]: Build started by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:24.105108+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=b779201e-bb33-420a-9aea-cd67d026040e fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:18:48.614900+00:00 app[api]: Deploy c57e0dc3 by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:48.614900+00:00 app[api]: Release v4 created by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:48.892841+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-06T00:18:49.000000+00:00 app[api]: Build succeeded
2019-12-06T00:18:52.277413+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-06T00:18:55.506035+00:00 app[web.1]:
2019-12-06T00:18:55.506063+00:00 app[web.1]: > 1-Heroku#1.0.0 start /app
2019-12-06T00:18:55.506065+00:00 app[web.1]: > node src/app.js
2019-12-06T00:18:55.506067+00:00 app[web.1]:
2019-12-06T00:18:55.809888+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-06T00:18:55.809932+00:00 app[web.1]: throw err;
2019-12-06T00:18:55.809934+00:00 app[web.1]: ^
2019-12-06T00:18:55.809936+00:00 app[web.1]:
2019-12-06T00:18:55.809939+00:00 app[web.1]: Error: Cannot find module 'hbs'
2019-12-06T00:18:55.809941+00:00 app[web.1]: Require stack:
2019-12-06T00:18:55.809943+00:00 app[web.1]: - /app/src/app.js
2019-12-06T00:18:55.809945+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-06T00:18:55.809947+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-06T00:18:55.809950+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-06T00:18:55.809952+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-06T00:18:55.809954+00:00 app[web.1]: at Object.<anonymous> (/app/src/app.js:5:13)
2019-12-06T00:18:55.809956+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-06T00:18:55.809958+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-06T00:18:55.809960+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-06T00:18:55.809962+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-06T00:18:55.809964+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:18:55.809966+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:18:55.809968+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:18:55.809970+00:00 app[web.1]: }
2019-12-06T00:18:55.853916+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:18:55.854597+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:18:55.858952+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:18:55.859163+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:18:55.859694+00:00 app[web.1]: npm ERR!
2019-12-06T00:18:55.859697+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:18:55.859764+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:18:55.917128+00:00 app[web.1]:
2019-12-06T00:18:55.917132+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:18:55.917135+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_18_55_860Z-debug.log
2019-12-06T00:18:56.015418+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:18:55.990556+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:18:57.272264+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=1371d608-aa3d-4ada-94bb-cde5f9edfd69 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:21:46.461037+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-06T00:21:49.272673+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-06T00:21:53.501754+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:21:53.116284+00:00 app[web.1]:
2019-12-06T00:21:53.116306+00:00 app[web.1]: > 1-Heroku#1.0.0 start /app
2019-12-06T00:21:53.116308+00:00 app[web.1]: > node src/app.js
2019-12-06T00:21:53.116310+00:00 app[web.1]:
2019-12-06T00:21:53.306576+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-06T00:21:53.306580+00:00 app[web.1]: throw err;
2019-12-06T00:21:53.306583+00:00 app[web.1]: ^
2019-12-06T00:21:53.306586+00:00 app[web.1]:
2019-12-06T00:21:53.306588+00:00 app[web.1]: Error: Cannot find module 'hbs'
2019-12-06T00:21:53.306591+00:00 app[web.1]: Require stack:
2019-12-06T00:21:53.306596+00:00 app[web.1]: - /app/src/app.js
2019-12-06T00:21:53.306598+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-06T00:21:53.306600+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-06T00:21:53.306603+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-06T00:21:53.306605+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-06T00:21:53.306607+00:00 app[web.1]: at Object.<anonymous> (/app/src/app.js:5:13)
2019-12-06T00:21:53.306609+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-06T00:21:53.306611+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-06T00:21:53.306613+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-06T00:21:53.306616+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-06T00:21:53.306618+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:21:53.306620+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:21:53.306622+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:21:53.306624+00:00 app[web.1]: }
2019-12-06T00:21:53.321267+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:21:53.321742+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:21:53.324564+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:21:53.324972+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:21:53.325528+00:00 app[web.1]: npm ERR!
2019-12-06T00:21:53.326031+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:21:53.326436+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:21:53.342561+00:00 app[web.1]:
2019-12-06T00:21:53.342869+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:21:53.343077+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_21_53_327Z-debug.log
2019-12-06T00:21:53.479134+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:22:24.106302+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=fbd6f731-b6f7-49c1-b1ed-2373fd79d7d1 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:31:08.844509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=f109e557-116b-4915-8c50-82520f635a42 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
my app.js
const express = require('express')
const path = require('path')
const app = express()
const appRoute = require('./routes/app.js')
const hbs = require( 'hbs')
const port = process.env.PORT||3001
const publicPath = path.join(__dirname + '../../public')
const partialsPath = path.join(__dirname + '/template/partials')
const viewPath = path.join(__dirname + '/template/views')
//HBS
app.set('view engine', 'hbs')
app.set('views', viewPath)
hbs.registerPartials(partialsPath)
app.use(express.static(publicPath))
//ROUTES
app.use(appRoute)
app.listen(port)
my package.js script
"scripts": {
"build": "webpack",
"watch": "webpack --watch",
"dev": "nodemon src/app.js",
"start": "node src/app.js"
},
My Node + Express server is working locally but not on Heroku.
Also worth mentioning I'm using heroku-postgres and ran these commands
heroku run knex migrate:latest -a myAppName
heroku run knex seed:latest -a myAppName
The commands ran successfully and I can see the seeded DB on Heroku.
What's the issue?
Now when I try to access the server, it just won't work because of some modules it can't find, but again it works perfectly on my end
I'm also deploying from my development-branch, haven't yet merged to master but that shouldn't be the problem.
Heroku Logs:
2019-11-20T19:57:57.678058+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-20T19:57:57.524659+00:00 app[web.1]: internal/modules/cjs/loader.js:895
2019-11-20T19:57:57.524683+00:00 app[web.1]: throw err;
2019-11-20T19:57:57.524685+00:00 app[web.1]: ^
2019-11-20T19:57:57.524686+00:00 app[web.1]:
2019-11-20T19:57:57.524689+00:00 app[web.1]: Error: Cannot find module '../../Users/Middlewares/validateUserID'
2019-11-20T19:57:57.524690+00:00 app[web.1]: Require stack:
2019-11-20T19:57:57.524692+00:00 app[web.1]: - /app/Issues/Routes/IssueRoutes.js
2019-11-20T19:57:57.524694+00:00 app[web.1]: - /app/api/server.js
2019-11-20T19:57:57.524695+00:00 app[web.1]: - /app/index.js
2019-11-20T19:57:57.524697+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
2019-11-20T19:57:57.524698+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:785:27)
2019-11-20T19:57:57.524700+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:57:57.524702+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:57:57.524703+00:00 app[web.1]: at Object.<anonymous> (/app/Issues/Routes/IssueRoutes.js:6:28)
2019-11-20T19:57:57.524704+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:57:57.524706+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:57:57.524707+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:57:57.524708+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14)
2019-11-20T19:57:57.524710+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:57:57.524711+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:57:57.524712+00:00 app[web.1]: at Object.<anonymous> (/app/api/server.js:10:21)
2019-11-20T19:57:57.524713+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:57:57.524715+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:57:57.524716+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:57:57.524717+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14) {
2019-11-20T19:57:57.524718+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-11-20T19:57:57.524720+00:00 app[web.1]: requireStack: [
2019-11-20T19:57:57.524721+00:00 app[web.1]: '/app/Issues/Routes/IssueRoutes.js',
2019-11-20T19:57:57.524722+00:00 app[web.1]: '/app/api/server.js',
2019-11-20T19:57:57.524724+00:00 app[web.1]: '/app/index.js'
2019-11-20T19:57:57.524725+00:00 app[web.1]: ]
2019-11-20T19:57:57.524726+00:00 app[web.1]: }
2019-11-20T19:57:57.533660+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-20T19:57:57.534079+00:00 app[web.1]: npm ERR! errno 1
2019-11-20T19:57:57.536043+00:00 app[web.1]: npm ERR! bettercity#1.0.0 start: `node index.js`
2019-11-20T19:57:57.536045+00:00 app[web.1]: npm ERR! Exit status 1
2019-11-20T19:57:57.536154+00:00 app[web.1]: npm ERR!
2019-11-20T19:57:57.536817+00:00 app[web.1]: npm ERR! Failed at the bettercity#1.0.0 start script.
2019-11-20T19:57:57.536821+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-11-20T19:57:57.563676+00:00 app[web.1]:
2019-11-20T19:57:57.564106+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-20T19:57:57.564508+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-20T19_57_57_537Z-debug.log
2019-11-20T19:57:57.659267+00:00 heroku[web.1]: Process exited with status 1
2019-11-20T19:58:25.000000+00:00 app[api]: Build started by user myEmail#mail.com
2019-11-20T19:59:21.041005+00:00 app[api]: Deploy a1b6ff8e by user myEmail#mail.com
2019-11-20T19:59:21.041005+00:00 app[api]: Release v20 created by user myEmail#mail.com
2019-11-20T19:59:21.000000+00:00 app[api]: Build succeeded
2019-11-20T19:59:22.528003+00:00 heroku[web.1]: State changed from crashed to starting
2019-11-20T19:59:26.144682+00:00 heroku[web.1]: Starting process with command `npm start`
2019-11-20T19:59:29.286295+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-20T19:59:28.777609+00:00 app[web.1]:
2019-11-20T19:59:28.777626+00:00 app[web.1]: > bettercity#1.0.0 start /app
2019-11-20T19:59:28.777628+00:00 app[web.1]: > node index.js
2019-11-20T19:59:28.777629+00:00 app[web.1]:
2019-11-20T19:59:29.268829+00:00 heroku[web.1]: Process exited with status 1
2019-11-20T19:59:29.169740+00:00 app[web.1]: internal/modules/cjs/loader.js:895
2019-11-20T19:59:29.169765+00:00 app[web.1]: throw err;
2019-11-20T19:59:29.169766+00:00 app[web.1]: ^
2019-11-20T19:59:29.169767+00:00 app[web.1]:
2019-11-20T19:59:29.169779+00:00 app[web.1]: Error: Cannot find module '../../Users/Middlewares/validateUserID'
2019-11-20T19:59:29.169780+00:00 app[web.1]: Require stack:
2019-11-20T19:59:29.169781+00:00 app[web.1]: - /app/Issues/Routes/IssueRoutes.js
2019-11-20T19:59:29.169782+00:00 app[web.1]: - /app/api/server.js
2019-11-20T19:59:29.169783+00:00 app[web.1]: - /app/index.js
2019-11-20T19:59:29.169784+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
2019-11-20T19:59:29.169785+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:785:27)
2019-11-20T19:59:29.169786+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:59:29.169787+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:59:29.169788+00:00 app[web.1]: at Object.<anonymous> (/app/Issues/Routes/IssueRoutes.js:6:28)
2019-11-20T19:59:29.169789+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:59:29.169790+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:59:29.169791+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:59:29.169792+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14)
2019-11-20T19:59:29.169793+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:59:29.169794+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:59:29.169795+00:00 app[web.1]: at Object.<anonymous> (/app/api/server.js:10:21)
2019-11-20T19:59:29.169796+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:59:29.169797+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:59:29.169798+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:59:29.169799+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14) {
2019-11-20T19:59:29.169800+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-11-20T19:59:29.169801+00:00 app[web.1]: requireStack: [
2019-11-20T19:59:29.169802+00:00 app[web.1]: '/app/Issues/Routes/IssueRoutes.js',
2019-11-20T19:59:29.169803+00:00 app[web.1]: '/app/api/server.js',
2019-11-20T19:59:29.169804+00:00 app[web.1]: '/app/index.js'
2019-11-20T19:59:29.169805+00:00 app[web.1]: ]
2019-11-20T19:59:29.169806+00:00 app[web.1]: }
2019-11-20T19:59:29.179485+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-20T19:59:29.179812+00:00 app[web.1]: npm ERR! errno 1
2019-11-20T19:59:29.181606+00:00 app[web.1]: npm ERR! bettercity#1.0.0 start: `node index.js`
2019-11-20T19:59:29.181811+00:00 app[web.1]: npm ERR! Exit status 1
2019-11-20T19:59:29.182146+00:00 app[web.1]: npm ERR!
2019-11-20T19:59:29.182403+00:00 app[web.1]: npm ERR! Failed at the bettercity#1.0.0 start script.
2019-11-20T19:59:29.182699+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-11-20T19:59:29.198787+00:00 app[web.1]:
2019-11-20T19:59:29.199117+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-20T19:59:29.199119+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-20T19_59_29_183Z-debug.log
package.json
{
"name": "bettercity",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rodpa715/bettercity.git"
},
"author": "Patrick Rodrigues",
"license": "ISC",
"bugs": {
"url": "https://github.com/rodpa715/bettercity/issues"
},
"homepage": "https://github.com/rodpa715/bettercity#readme",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^3.21.2",
"jsonwebtoken": "^8.5.1",
"knex": "^0.20.2",
"node": "^13.1.0",
"pg": "^7.12.1"
},
"engines": {
"node": "^10.16.3",
"npm": "6.13.0"
},
"devDependencies": {
"jest": "^24.9.0",
"nodemon": "^1.19.4",
"supertest": "^4.0.2"
}
}
[SOLVED]
It seems as though GitHub doesn't track folder case-sensitivity change so even when I renamed the folders it didn't work. I copied everything into a new repo and it deployed successfully.
Try changing
const { validateUserID } = require("../../Users/Middlewares/validateUserID");
to
const { validateUserID } = require("../../users/Middlewares/validateUserID");
with a lowercase users
linux is case sensitive and it might be giving issues on a server but not on your machine if you have a mac.
Your paths to the routes are incorrect and node cannot find those in the Heroku filesystem.
Work off your current file using like './' so you update to:
const authRoutes = require("./../Authentication/Routes/AuthRoutes");
I have looked through a lot of similar topics and have so far been unable to resolve my problem.
I created a MERN app, used Amazon for my assets and tried to deploy it on Heroku.
My app works locally but when I deployed it on Heroku, I got a 'Application Error'.
When I take a look at the heroku logs --tail, this is the final errors I got :
2019-04-27T12:49:01.084214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-earth-15269.herokuapp.com request_id=b2953cc1-6894-4697-8fc4-17d5012c536e fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
2019-04-27T12:49:01.622395+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-earth-15269.herokuapp.com request_id=2a9fbdbb-a35d-4ba1-a032-b263110e10db fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
And this is the complete log :
2019-04-27T12:48:09.000000+00:00 app[api]: Build succeeded
2019-04-27T12:48:24.009559+00:00 heroku[web.1]: Starting process with command `npm start`
2019-04-27T12:48:27.790744+00:00 app[web.1]:
2019-04-27T12:48:27.790767+00:00 app[web.1]: > joystock#1.0.0 start /app
2019-04-27T12:48:27.790768+00:00 app[web.1]: > node server.js
2019-04-27T12:48:27.790770+00:00 app[web.1]:
2019-04-27T12:48:29.369354+00:00 app[web.1]:
2019-04-27T12:48:29.369392+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:465
2019-04-27T12:48:29.369396+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-04-27T12:48:29.369397+00:00 app[web.1]: ^
2019-04-27T12:48:29.369917+00:00 app[web.1]: 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-04-27T12:48:29.369920+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:14:11)
2019-04-27T12:48:29.369923+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:465:11)
2019-04-27T12:48:29.369925+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:289:15)
2019-04-27T12:48:29.369928+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:25:4)
2019-04-27T12:48:29.369930+00:00 app[web.1]: at Module._compile (module.js:653:30)
2019-04-27T12:48:29.369932+00:00 app[web.1]: at Object.Module._extensions..js (module.js:664:10)
2019-04-27T12:48:29.369933+00:00 app[web.1]: at Module.load (module.js:566:32)
2019-04-27T12:48:29.369935+00:00 app[web.1]: at tryModuleLoad (module.js:506:12)
2019-04-27T12:48:29.369936+00:00 app[web.1]: at Function.Module._load (module.js:498:3)
2019-04-27T12:48:29.369938+00:00 app[web.1]: at Function.Module.runMain (module.js:694:10)
2019-04-27T12:48:29.369939+00:00 app[web.1]: at startup (bootstrap_node.js:204:16)
2019-04-27T12:48:29.369942+00:00 app[web.1]: at bootstrap_node.js:625:3
2019-04-27T12:48:29.430850+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-27T12:48:29.434765+00:00 app[web.1]: npm ERR! errno 1
2019-04-27T12:48:29.436805+00:00 app[web.1]: npm ERR! joystock#1.0.0 start: `node server.js`
2019-04-27T12:48:29.437062+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-27T12:48:29.437419+00:00 app[web.1]: npm ERR!
2019-04-27T12:48:29.437721+00:00 app[web.1]: npm ERR! Failed at the joystock#1.0.0 start script.
2019-04-27T12:48:29.438013+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-27T12:48:29.457869+00:00 app[web.1]:
2019-04-27T12:48:29.458356+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-27T12:48:29.458709+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-27T12_48_29_440Z-debug.log
2019-04-27T12:48:29.555420+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-27T12:48:29.559599+00:00 heroku[web.1]: State changed from crashed to starting
2019-04-27T12:48:29.536335+00:00 heroku[web.1]: Process exited with status 1
2019-04-27T12:48:38.161883+00:00 heroku[web.1]: Starting process with command `npm start`
2019-04-27T12:48:40.468366+00:00 app[web.1]:
2019-04-27T12:48:40.468385+00:00 app[web.1]: > joystock#1.0.0 start /app
2019-04-27T12:48:40.468387+00:00 app[web.1]: > node server.js
2019-04-27T12:48:40.468388+00:00 app[web.1]:
2019-04-27T12:48:41.210741+00:00 app[web.1]:
2019-04-27T12:48:41.210778+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:465
2019-04-27T12:48:41.210781+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-04-27T12:48:41.210783+00:00 app[web.1]: ^
2019-04-27T12:48:41.211208+00:00 app[web.1]: 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-04-27T12:48:41.211212+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:14:11)
2019-04-27T12:48:41.211214+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:465:11)
2019-04-27T12:48:41.211216+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:289:15)
2019-04-27T12:48:41.211218+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:25:4)
2019-04-27T12:48:41.211219+00:00 app[web.1]: at Module._compile (module.js:653:30)
2019-04-27T12:48:41.211221+00:00 app[web.1]: at Object.Module._extensions..js (module.js:664:10)
2019-04-27T12:48:41.211222+00:00 app[web.1]: at Module.load (module.js:566:32)
2019-04-27T12:48:41.211224+00:00 app[web.1]: at tryModuleLoad (module.js:506:12)
2019-04-27T12:48:41.211225+00:00 app[web.1]: at Function.Module._load (module.js:498:3)
2019-04-27T12:48:41.211227+00:00 app[web.1]: at Function.Module.runMain (module.js:694:10)
2019-04-27T12:48:41.211228+00:00 app[web.1]: at startup (bootstrap_node.js:204:16)
2019-04-27T12:48:41.211231+00:00 app[web.1]: at bootstrap_node.js:625:3
2019-04-27T12:48:41.220629+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-27T12:48:41.221020+00:00 app[web.1]: npm ERR! errno 1
2019-04-27T12:48:41.222262+00:00 app[web.1]: npm ERR! joystock#1.0.0 start: `node server.js`
2019-04-27T12:48:41.222424+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-27T12:48:41.222687+00:00 app[web.1]: npm ERR!
2019-04-27T12:48:41.222855+00:00 app[web.1]: npm ERR! Failed at the joystock#1.0.0 start script.
2019-04-27T12:48:41.223019+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-27T12:48:41.228089+00:00 app[web.1]:
2019-04-27T12:48:41.228288+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-27T12:48:41.228431+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-27T12_48_41_224Z-debug.log
2019-04-27T12:48:41.314693+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-27T12:48:41.291941+00:00 heroku[web.1]: Process exited with status 1
2019-04-27T12:49:01.084214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-earth-15269.herokuapp.com request_id=b2953cc1-6894-4697-8fc4-17d5012c536e fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
2019-04-27T12:49:01.622395+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-earth-15269.herokuapp.com request_id=2a9fbdbb-a35d-4ba1-a032-b263110e10db fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
I've already tried/checked :
The port
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Joystock Server running on port ${port}`));
Tried :
heroku restart
Add the engines version in my package.json file
"engines": {
"node": "8.12.0",
"npm": "6.4.1"
},
My config vars (mongoURI) are correctly defined in my heroku settings for this app.
I also tried to recreate the app completely, from scratch, and everything is up to date.
At first, I add no route defined for '/', so I tried to add one in routes/tracks.js
router.get('/', (req, res) => {
res.redirect('/all/page-1');
});
With or without this route, I got the same result.
...and I always end up with the same errors.
This is my current git repos for this app :
https://github.com/Karaza/joystock
I am out of ideas for what to try to do next for fixing my app.
Thank you in advance for you help (:
in file: joystock/config/keys.js... ensure that NODE_ENV is production? there no keys_dev file.
if (process.env.NODE_ENV === 'production') {
module.exports = require('./keys_prod');
} else {
module.exports = require('./keys_dev');
}
i'm not familiar with heroku, but looks like you disable production mode.
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
So i think need check:
process.env.MONGO_URI
process.env.NODE_ENV
In my config vars, I tried to define mongoURI instead of MONGO_URI
It's working now :)