My app successfully deployed to Heroku..
****: Deployed 6bc02eb8 Today at 4:19 PM · v23 · Compare diff **** ****: Build succeeded Today at 4:18 PM · View build log
But It shows error when try to open my app...
2022-06-29T10:19:45.228279 00:00 app[web.1]: npm ERR! 2022-06-29T10:19:45.228377 00:00 app[web.1]: npm ERR! Failed at the [email protected] start script. 2022-06-29T10:19:45.228470 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2022-06-29T10:19:45.236802 00:00 app[web.1]: 2022-06-29T10:19:45.237020 00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-06-29T10:19:45.237112 00:00 app[web.1]: npm ERR!
/app/.npm/_logs/2022-06-29T10_19_45_229Z-debug.log 2022-06-29T10:19:45.431649 00:00 heroku[web.1]: Process exited with status 1 2022-06-29T10:19:45.541882 00:00 heroku[web.1]: State changed from starting to crashed 2022-06-29T10:19:48.705353 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=syt-share-your-thoughts.herokuapp.com request_id=0bb2aaff-6bce-41fb-891e-d3b361a122f8 fwd="59.153.103.22" dyno= connect= service= status=503 bytes= protocol=https 2022-06-29T10:19:51.151462 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=syt-share-your-thoughts.herokuapp.com request_id=c0d24108-01a7-44b7-96dd-e8cc62bcaa7c fwd="59.153.103.22" dyno= connect= service= status=503 bytes= protocol=https
here is my package.json file:
{
"name": "blog-application",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js"
},
"author": "Md Shareful Islam",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.11",
"config": "^3.3.7",
"connect-flash": "^0.1.1",
"connect-mongodb-session": "^3.1.1",
"debug": "^4.3.4",
"dotenv": "^16.0.1",
"ejs": "^3.1.8",
"express": "^4.18.1",
"express-session": "^1.17.3",
"express-validator": "^6.14.1",
"moment": "^2.29.3",
"mongoose": "^6.3.8",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"nodemon": "^2.0.16",
"reading-time": "^1.5.0",
"validator": "^13.7.0"
},
"engines": {
"node": "14.15.5"
}
}
And this is my main file:
require('dotenv').config()
const express = require('express');
const mongoose = require('mongoose')
const config = require('config')
const chalk = require('chalk')
// import middleware
const setMiddleware = require('./middleware/middleware')
//Import Routes
const setRoutes = require('./routes/routes')
const MONGODB_URI = `mongodb srv://${config.get('db-admin')}:${config.get('db-password')}@blogapp.ool50gr.mongodb.net/?retryWrites=true&w=majority`
const app = express();
// Setup View Engine
app.set('view engine', 'ejs')
app.set('views', 'views')
// Using Middleware from Middleware Directory
setMiddleware(app)
// Using Routes from Route Directory
setRoutes(app)
// ** middleware to handle 404 and 500.
app.use((req, res, next) => {
let error = new Error('404 Page Not Found');
error.status = 404;
next(error);
})
app.use((error, req, res, next) => {
if(error.status === 404) {
return res.render('pages/error/404', {flashMessage: {}})
}
res.render('pages/error/500', {flashMessage: {}})
})
const PORT = process.env.PORT || 8080;
mongoose.connect(MONGODB_URI,
{useNewUrlParser: true})
.then(() => {
console.log(chalk.green.bold('Database connected!'))
app.listen(PORT, () => {
console.log(chalk.green.italic(`App is running on PORT ${PORT}`));
});
})
.catch(e => {
return console.log(e)
})
Here are logs datails from Heroku...
2022-06-29T16:18:56.404997 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-06-29T16:18:56.405076 00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-06-29T16_18_56_398Z-debug.log
2022-06-29T16:18:56.554135 00:00 heroku[web.1]: Process exited with status 1
2022-06-29T16:18:56.637092 00:00 heroku[web.1]: State changed from starting to crashed
2022-06-29T16:18:56.640222 00:00 heroku[web.1]: State changed from crashed to starting
2022-06-29T16:19:00.220649 00:00 heroku[web.1]: Starting process with command `npm start`
2022-06-29T16:19:03.473783 00:00 app[web.1]:
2022-06-29T16:19:03.473792 00:00 app[web.1]: > [email protected] start /app
2022-06-29T16:19:03.473792 00:00 app[web.1]: > node app.js
2022-06-29T16:19:03.473792 00:00 app[web.1]:
2022-06-29T16:19:35.090006 00:00 app[web.1]: /app/node_modules/mongodb/lib/utils.js:417
2022-06-29T16:19:35.090017 00:00 app[web.1]: throw error;
2022-06-29T16:19:35.090018 00:00 app[web.1]: ^
2022-06-29T16:19:35.090019 00:00 app[web.1]:
2022-06-29T16:19:35.090020 00:00 app[web.1]: Error: Error connecting to db: connection <monitor> to 13.250.175.230:27017 closed
2022-06-29T16:19:35.090021 00:00 app[web.1]: at /app/node_modules/connect-mongodb-session/index.js:88:17
2022-06-29T16:19:35.090021 00:00 app[web.1]: at /app/node_modules/mongodb/lib/utils.js:413:17
2022-06-29T16:19:35.090022 00:00 app[web.1]: at /app/node_modules/mongodb/lib/mongo_client.js:129:28
2022-06-29T16:19:35.090022 00:00 app[web.1]: at connectCallback (/app/node_modules/mongodb/lib/operations/connect.js:29:9)
2022-06-29T16:19:35.090023 00:00 app[web.1]: at /app/node_modules/mongodb/lib/operations/connect.js:78:20
2022-06-29T16:19:35.090023 00:00 app[web.1]: at Object.callback (/app/node_modules/mongodb/lib/sdam/topology.js:208:50)
2022-06-29T16:19:35.090024 00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/sdam/topology.js:319:33)
2022-06-29T16:19:35.090024 00:00 app[web.1]: at listOnTimeout (internal/timers.js:554:17)
2022-06-29T16:19:35.090024 00:00 app[web.1]: at processTimers (internal/timers.js:497:7)
2022-06-29T16:19:35.109275 00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-06-29T16:19:35.109568 00:00 app[web.1]: npm ERR! errno 1
2022-06-29T16:19:35.113501 00:00 app[web.1]: npm ERR! [email protected] start: `node app.js`
2022-06-29T16:19:35.113599 00:00 app[web.1]: npm ERR! Exit status 1
2022-06-29T16:19:35.113705 00:00 app[web.1]: npm ERR!
2022-06-29T16:19:35.113792 00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2022-06-29T16:19:35.113876 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-06-29T16:19:35.120692 00:00 app[web.1]:
2022-06-29T16:19:35.120808 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-06-29T16:19:35.120859 00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-06-29T16_19_35_114Z-debug.log
2022-06-29T16:19:35.785417 00:00 heroku[web.1]: State changed from starting to crashed
2022-06-29T16:19:35.273101 00:00 heroku[web.1]: Process exited with status 1
2022-06-29T16:19:38.894464 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=syt-share-your-thoughts.herokuapp.com request_id=2b13bcd5-e764-4e60-a254-394a8b0f7531 fwd="59.153.103.22" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T16:19:41.185482 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=syt-share-your-thoughts.herokuapp.com request_id=6109b89a-818d-4827-804b-98c1a875a3ab fwd="59.153.103.22" dyno= connect= service= status=503 bytes= protocol=https
CodePudding user response:
you don't provide enought information for us to be able to help you, nobody can or will debug it for you in that regard.
Here, sharing your package.json
and the entry file of your application would be useful!
Anyway it seems that npm run start
is crashing, you could start by making sure that whatever command is run by npm run start
is accessible in heroku (You might use a global dependencies that you have installed on your local machine which heroku doesn't).
I'll be glad to help you more if you provide required code snippets for us to understand what's happening!