При публикации проекта на сервер heroku возникает ошибка Application error.
Ранее публиковал несколько проектов связки nodejs-express-mysql
данные проекты работают и до сегодня.
Все делал по следующему алгоритму:
1) git init
2) git add .
3) git commit -am 'message'
Перейти к хероку
1) heroku login
2) heroku create и имя проекта или оставить пустым
3) git push heroku master
Создал самый простой проект - с отображением двух страниц Home, About без какой либо логики - Application error.
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const PORT = process.env.PORT || 3010;
const cors = require('cors');
app.use(bodyParser.json()); //добавляем код до наших маршрутов
app.use(bodyParser.urlencoded({extended: true}));
app.use(cors());
app.get('/', (req, res) => {
res.send('Home page');
});
app.get('/about', (req, res) => {
res.send('About page');
});
//404
app.use((req,res,next) => {
res.status(404).send('Error 404!');
});
app.listen(PORT, () => {
console.log(`Порт запущен по адресу: ${PORT}`);
});
Описание файла package.json
{
"name": "testing",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1"
}
}
Лог файл - сформированный командой heroku logs --tail
2021-04-06T11:20:03.192245+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=testing-04445.herokuapp.com request_id=f73b8ab0-74c0-4a6b
-ab6e-f97f83f0fa56 fwd="188.163.7.204" dyno= connect= service= status=502 bytes= protocol=https
2021-04-06T11:20:03.991620+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=testing-04445.herokuapp.com request_id=65ff230
3-9776-4d97-be75-02fc6bbd0d71 fwd="188.163.7.204" dyno= connect= service= status=502 bytes= protocol=https
2021-04-06T11:20:40.000000+00:00 app[api]: Build started by user willberies@meta.ua
2021-04-06T11:21:05.000000+00:00 app[api]: Build succeeded
2021-04-06T11:21:05.016450+00:00 app[api]: Deploy 83887fe9 by user willberies@meta.ua
2021-04-06T11:21:05.016450+00:00 app[api]: Release v3 created by user willberies@meta.ua
2021-04-06T11:21:05.032201+00:00 app[api]: Scaled to web@1:Free by user willberies@meta.ua
2021-04-06T11:21:08.814982+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-06T11:21:12.669857+00:00 app[web.1]:
2021-04-06T11:21:12.669878+00:00 app[web.1]: > testing@1.0.0 start /app
2021-04-06T11:21:12.669878+00:00 app[web.1]: > node app.js
2021-04-06T11:21:12.669879+00:00 app[web.1]:
2021-04-06T11:21:12.803468+00:00 app[web.1]: internal/modules/cjs/loader.js:883
2021-04-06T11:21:12.803470+00:00 app[web.1]: throw err;
2021-04-06T11:21:12.803470+00:00 app[web.1]: ^
2021-04-06T11:21:12.803471+00:00 app[web.1]:
2021-04-06T11:21:12.803471+00:00 app[web.1]: Error: Cannot find module 'express'
2021-04-06T11:21:12.803471+00:00 app[web.1]: Require stack:
2021-04-06T11:21:12.803472+00:00 app[web.1]: - /app/app.js
2021-04-06T11:21:12.803472+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
2021-04-06T11:21:12.803473+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-06T11:21:12.803473+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2021-04-06T11:21:12.803474+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
2021-04-06T11:21:12.803474+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:1:17)
2021-04-06T11:21:12.803475+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-04-06T11:21:12.803475+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-04-06T11:21:12.803476+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-04-06T11:21:12.803476+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-04-06T11:21:12.803476+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
2021-04-06T11:21:12.803477+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-06T11:21:12.803477+00:00 app[web.1]: requireStack: [ '/app/app.js' ]
2021-04-06T11:21:12.803478+00:00 app[web.1]: }
2021-04-06T11:21:12.831308+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-06T11:21:12.832002+00:00 app[web.1]: npm ERR! errno 1
2021-04-06T11:21:12.841050+00:00 app[web.1]: npm ERR! testing@1.0.0 start: `node app.js`
2021-04-06T11:21:12.841343+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-06T11:21:12.841635+00:00 app[web.1]: npm ERR!
2021-04-06T11:21:12.841919+00:00 app[web.1]: npm ERR! Failed at the testing@1.0.0 start script.
2021-04-06T11:21:12.842166+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-06T11:21:12.849968+00:00 app[web.1]:
2021-04-06T11:21:12.856765+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-06T11:21:12.856992+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-04-06T11_21_12_843Z-debug.log
2021-04-06T11:21:13.029718+00:00 heroku[web.1]: Process exited with status 1
2021-04-06T11:21:13.430319+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-06T11:21:13.433595+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-06T11:21:15.842022+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-06T11:21:18.572969+00:00 app[web.1]:
2021-04-06T11:21:18.572993+00:00 app[web.1]: > testing@1.0.0 start /app
2021-04-06T11:21:18.572993+00:00 app[web.1]: > node app.js
2021-04-06T11:21:18.572994+00:00 app[web.1]:
2021-04-06T11:21:18.663985+00:00 app[web.1]: internal/modules/cjs/loader.js:883
2021-04-06T11:21:18.663986+00:00 app[web.1]: throw err;
2021-04-06T11:21:18.663987+00:00 app[web.1]: ^
2021-04-06T11:21:18.663987+00:00 app[web.1]:
2021-04-06T11:21:18.663988+00:00 app[web.1]: Error: Cannot find module 'express'
2021-04-06T11:21:18.663988+00:00 app[web.1]: Require stack:
2021-04-06T11:21:18.663989+00:00 app[web.1]: - /app/app.js
2021-04-06T11:21:18.663989+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
2021-04-06T11:21:18.663990+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-06T11:21:18.663990+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2021-04-06T11:21:18.663991+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
2021-04-06T11:21:18.663991+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:1:17)
2021-04-06T11:21:18.663992+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-04-06T11:21:18.663992+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-04-06T11:21:18.663993+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-04-06T11:21:18.663993+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-04-06T11:21:18.663994+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
2021-04-06T11:21:18.663994+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-06T11:21:18.663995+00:00 app[web.1]: requireStack: [ '/app/app.js' ]
2021-04-06T11:21:18.663995+00:00 app[web.1]: }
2021-04-06T11:21:18.679474+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-06T11:21:18.679932+00:00 app[web.1]: npm ERR! errno 1
2021-04-06T11:21:18.685943+00:00 app[web.1]: npm ERR! testing@1.0.0 start: `node app.js`
2021-04-06T11:21:18.686114+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-06T11:21:18.686344+00:00 app[web.1]: npm ERR!
2021-04-06T11:21:18.686389+00:00 app[web.1]: npm ERR! Failed at the testing@1.0.0 start script.
2021-04-06T11:21:18.686489+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-06T11:21:18.695428+00:00 app[web.1]:
2021-04-06T11:21:18.765009+00:00 heroku[web.1]: Process exited with status 1
2021-04-06T11:21:18.895573+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-06T11:23:16.794166+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testing-04445.herokuapp.com request_id=84e1442f-fefc-4