Reputation: 59
I have attempted various resolutions; using GitHub as the deployment method, installing the NPM package serve, force cleaning cache, re-installing node_modules & package-lock.json and even switching the project from NPM to Yarn. I still get the following error.
Error log:
2022-01-17T16:20:29.660758+00:00 heroku[web.1]: Process exited with status 1 2022-01-17T16:20:29.752386+00:00 heroku[web.1]: State changed from starting to crashed 2022-01-17T16:20:30.611091+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ip-tracker-app.herokuapp.com request_id=a46f3082-43fd-45e9-a049-d1076cad194f fwd="2.125.111.225" dyno= connect= service= status=503 bytes= protocol=https 2022-01-17T16:20:31.020509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ip-tracker-app.herokuapp.com request_id=c01ac432-ae1c-4994-9fa0-b211a8f00391 fwd="2.125.111.225" dyno= connect= service= status=503 bytes= protocol=https
My Package.json file:
{
"name": "ip-address-tracker",
"version": "1.0.0",
"description": "*Removed for question*",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"start": "node server.js",
"test": "jest --coverage",
"devStart": "nodemon server.js"
},
"jest": {
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
}
},
"repository": {
"type": "git",
"url": "*Removed for question*"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "*Removed for question*",
},
"homepage": "*Removed for question*",
"dependencies": {
"dotenv": "^10.0.0",
"express": "^4.17.2",
"jest": "^27.4.7",
"serve": "^13.0.2"
},
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.8",
"babel-jest": "^27.4.6",
"nodemon": "^2.0.15",
"regenerator-runtime": "^0.13.9"
}
}
My server.js file:
const express = require('express');
const app = express();
const dotenv = require('dotenv');
const result = dotenv.config();
if (result.error) {
throw result.error;
}
const PORT = process.env.PORT || 3000;
app.use(express.static('public'));
app.listen(PORT, () => {
console.log(`App is listening on ${PORT}.`);
});
I have added the following Procfile:
web: npm start
Upvotes: 0
Views: 1006
Reputation: 343
I saw an issue on your serveur if you want to serve html file like dist try this instead
app.use('/', serveStatic(path.join(__dirname, '/public')))
If the purpose is to deliver image
app.use(express.static(path.join(__dirname,'public')))
Upvotes: 0