Я создаю приложение стека MERN.Мой Node-сервер работает локально и подключается к базе данных MongoDB.Он также строит и развертывает на Heroku.Но когда я нажимаю «Открыть приложение» на странице Heroku, появляется надпись «Ошибка приложения».
Я попытался изменить порт со статического порта на process.env.PORT в файле моего сервера.Я все еще получаю ошибку приложения.Я проверил журналы Heroku, но я не уверен, какая часть вызывает проблему или как ее исправить.
Это журналы Heroku:
Mikes-MacBook-Pro-2:MealAppeal mikemooney$ heroku logs --tail
2019-04-28T19:06:49.254157+00:00 app[web.1]: [0] at Function.Module._load (internal/modules/cjs/loader.js:531:3)
2019-04-28T19:06:49.258286+00:00 app[web.1]: [0] cd backend && node server.js exited with code 1
2019-04-28T19:06:49.523188+00:00 app[web.1]: [1]
2019-04-28T19:06:49.523200+00:00 app[web.1]: [1] > reactpractice@0.1.0 start /app/client
2019-04-28T19:06:49.523203+00:00 app[web.1]: [1] > react-scripts start
2019-04-28T19:06:49.523205+00:00 app[web.1]: [1]
2019-04-28T19:06:49.527698+00:00 app[web.1]: [1] sh: 1: react-scripts: not found
2019-04-28T19:06:49.531427+00:00 app[web.1]: [1] npm ERR! file sh
2019-04-28T19:06:49.531429+00:00 app[web.1]: [1] npm ERR! code ELIFECYCLE
2019-04-28T19:06:49.531715+00:00 app[web.1]: npm ERR! errno ENOENT
2019-04-28T19:06:49.531717+00:00 app[web.1]: [1] npm ERR! syscall spawn
2019-04-28T19:06:49.532769+00:00 app[web.1]: [1] npm ERR! reactpractice@0.1.0 start: `react-scripts start`
2019-04-28T19:06:49.532771+00:00 app[web.1]: [1] npm ERR! spawn ENOENT
2019-04-28T19:06:49.532772+00:00 app[web.1]: [1] npm ERR!
2019-04-28T19:06:49.536200+00:00 app[web.1]: npm ERR! Failed at the reactpractice@0.1.0 start script.
2019-04-28T19:06:49.536203+00:00 app[web.1]: [1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-28T19:06:49.595881+00:00 app[web.1]: [1] npm WARN Local package.json exists, but node_modules missing, did you mean to install?
2019-04-28T19:06:49.596389+00:00 app[web.1]: [1]
2019-04-28T19:06:49.596733+00:00 app[web.1]: [1] npm ERR! A complete log of this run can be found in:
2019-04-28T19:06:49.596736+00:00 app[web.1]: [1] npm ERR! /app/.npm/_logs/2019-04-28T19_06_49_533Z-debug.log
2019-04-28T19:06:49.601383+00:00 app[web.1]: [1] cd client && npm start exited with code 1
2019-04-28T19:06:49.610970+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-28T19:06:49.611416+00:00 app[web.1]: npm ERR! errno 1
2019-04-28T19:06:49.612556+00:00 app[web.1]: npm ERR! MealAppeal@1.0.0 start: `concurrently "cd backend && node server.js" "cd client && npm start"`
2019-04-28T19:06:49.612719+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-28T19:06:49.612968+00:00 app[web.1]: npm ERR!
2019-04-28T19:06:49.613142+00:00 app[web.1]: npm ERR! Failed at the MealAppeal@1.0.0 start script.
2019-04-28T19:06:49.613304+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-28T19:06:49.694297+00:00 app[web.1]:
2019-04-28T19:06:49.694458+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-28T19:06:49.694583+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-28T19_06_49_614Z-debug.log
2019-04-28T19:06:49.762585+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-28T19:06:49.740377+00:00 heroku[web.1]: Process exited with status 1
2019-04-28T19:06:49.982478+00:00 heroku[web.1]: State changed from crashed to starting
2019-04-28T19:06:53.516443+00:00 heroku[web.1]: Starting process with command `npm start`
2019-04-28T19:06:56.184569+00:00 app[web.1]:
2019-04-28T19:06:56.184587+00:00 app[web.1]: > MealAppeal@1.0.0 start /app
2019-04-28T19:06:56.184589+00:00 app[web.1]: > concurrently "cd backend && node server.js" "cd client && npm start"
2019-04-28T19:06:56.184591+00:00 app[web.1]:
2019-04-28T19:06:56.940574+00:00 app[web.1]: [0] internal/modules/cjs/loader.js:584
2019-04-28T19:06:56.940619+00:00 app[web.1]: [0] throw err;
2019-04-28T19:06:56.940622+00:00 app[web.1]: [0] ^
2019-04-28T19:06:56.940623+00:00 app[web.1]: [0]
2019-04-28T19:06:56.940625+00:00 app[web.1]: [0] Error: Cannot find module 'express'
2019-04-28T19:06:56.940628+00:00 app[web.1]: [0] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
2019-04-28T19:06:56.940630+00:00 app[web.1]: [0] at Function.Module._load (internal/modules/cjs/loader.js:508:25)
2019-04-28T19:06:56.940632+00:00 app[web.1]: [0] at Module.require (internal/modules/cjs/loader.js:637:17)
2019-04-28T19:06:56.940634+00:00 app[web.1]: [0] at require (internal/modules/cjs/helpers.js:22:18)
2019-04-28T19:06:56.940636+00:00 app[web.1]: [0] at Object.<anonymous> (/app/backend/server.js:1:79)
2019-04-28T19:06:56.940637+00:00 app[web.1]: [0] at Module._compile (internal/modules/cjs/loader.js:701:30)
2019-04-28T19:06:56.940639+00:00 app[web.1]: [0] at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
2019-04-28T19:06:56.940641+00:00 app[web.1]: [0] at Module.load (internal/modules/cjs/loader.js:600:32)
2019-04-28T19:06:56.940642+00:00 app[web.1]: [0] at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
2019-04-28T19:06:56.940644+00:00 app[web.1]: [0] at Function.Module._load (internal/modules/cjs/loader.js:531:3)
2019-04-28T19:06:56.944428+00:00 app[web.1]: [0] cd backend && node server.js exited with code 1
2019-04-28T19:06:57.311873+00:00 app[web.1]: [1]
2019-04-28T19:06:57.311886+00:00 app[web.1]: [1] > reactpractice@0.1.0 start /app/client
2019-04-28T19:06:57.311888+00:00 app[web.1]: [1] > react-scripts start
2019-04-28T19:06:57.311890+00:00 app[web.1]: [1]
2019-04-28T19:06:57.322012+00:00 app[web.1]: [1] sh: 1: react-scripts: not found
2019-04-28T19:06:57.332830+00:00 app[web.1]: [1] npm ERR! file sh
2019-04-28T19:06:57.333782+00:00 app[web.1]: [1] npm ERR! code ELIFECYCLE
2019-04-28T19:06:57.334066+00:00 app[web.1]: [1] npm ERR! errno ENOENT
2019-04-28T19:06:57.334452+00:00 app[web.1]: npm ERR! syscall spawn
2019-04-28T19:06:57.344495+00:00 app[web.1]: [1] npm ERR! reactpractice@0.1.0 start: `react-scripts start`
2019-04-28T19:06:57.344500+00:00 app[web.1]: [1] npm ERR! spawn ENOENT
2019-04-28T19:06:57.344503+00:00 app[web.1]: [1] npm ERR!
2019-04-28T19:06:57.344504+00:00 app[web.1]: [1] npm ERR! Failed at the reactpractice@0.1.0 start script.
2019-04-28T19:06:57.344506+00:00 app[web.1]: [1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-28T19:06:57.351532+00:00 app[web.1]: [1] npm WARN Local package.json exists, but node_modules missing, did you mean to install?
2019-04-28T19:06:57.351535+00:00 app[web.1]: [1]
2019-04-28T19:06:57.351537+00:00 app[web.1]: [1] npm ERR! A complete log of this run can be found in:
2019-04-28T19:06:57.351539+00:00 app[web.1]: [1] npm ERR! /app/.npm/_logs/2019-04-28T19_06_57_343Z-debug.log
2019-04-28T19:06:57.364856+00:00 app[web.1]: [1] cd client && npm start exited with code 1
2019-04-28T19:06:57.377876+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-28T19:06:57.378703+00:00 app[web.1]: npm ERR! errno 1
2019-04-28T19:06:57.380999+00:00 app[web.1]: npm ERR! MealAppeal@1.0.0 start: `concurrently "cd backend && node server.js" "cd client && npm start"`
2019-04-28T19:06:57.381328+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-28T19:06:57.381816+00:00 app[web.1]: npm ERR!
2019-04-28T19:06:57.382171+00:00 app[web.1]: npm ERR! Failed at the MealAppeal@1.0.0 start script.
2019-04-28T19:06:57.382478+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-28T19:06:57.390608+00:00 app[web.1]:
2019-04-28T19:06:57.391002+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-28T19:06:57.391234+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-28T19_06_57_384Z-debug.log
2019-04-28T19:06:57.513345+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-28T19:06:57.493309+00:00 heroku[web.1]: Process exited with status 1
2019-04-28T19:06:59.681145+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=7a653da1-edfd-4b92-b3ea-c49e10943b8f fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:07:06.536235+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=c5518b49-ccd6-4066-b193-e717609a2cec fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:08:21.969940+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=7e88ce38-894b-42ed-80bb-a43f51deec57 fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:08:42.534226+00:00 app[api]: Starting process with command `reset` by user
2019-04-28T19:08:45.263724+00:00 heroku[run.4224]: State changed from starting to up
2019-04-28T19:08:45.121272+00:00 heroku[run.4224]: Awaiting client
2019-04-28T19:08:45.142193+00:00 heroku[run.4224]: Starting process with command `reset`
2019-04-28T19:08:50.401585+00:00 heroku[run.4224]: State changed from up to complete
2019-04-28T19:08:50.384535+00:00 heroku[run.4224]: Process exited with status 0
2019-04-28T19:08:57.669820+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=d1c7bb40-f2b3-4132-a784-55b98ce3f75b fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:18:36.447223+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=8fe67168-8085-4fb7-8d6a-65280e1b5f5f fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:18:36.900372+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=20fc5556-c2c8-4938-9726-8096c704503c fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:23:39.919432+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=3e1c874d-db0f-4001-a736-c398bb16f3a7 fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
2019-04-28T19:24:35.668319+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mealappeal.herokuapp.com request_id=ddefce58-1014-429d-a585-1fe792609215 fwd="73.196.166.129" dyno= connect= service= status=503 bytes= protocol=https
Это мои файлы package.json:
Backend:
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"cors": "^2.8.5",
"express": "^4.16.4",
"mongodb": "^3.2.3",
"mongoose": "^5.5.2"
}
}
Front:
{
"name": "reactpractice",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001/",
"dependencies": {
"axios": "^0.18.0",
"jquery": "^3.3.1",
"mdreact": "^0.1.5",
"mdbreact": "^4.13.0",
"react": "^16.8.5",
"react-bootstrap": "^1.0.0-beta.6",
"react-dom": "^16.8.5",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"react-select": "^2.4.3",
"react-selectize": "^3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Root:
{
"name": "MealAppeal",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"concurrently": "^4.1.0",
"express-session": "^1.16.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "concurrently \"cd backend && node server.js\" \"cd client && npm start\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/mmooney363/MealAppeal.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/mmooney363/MealAppeal/issues"
},
"homepage": "https://github.com/mmooney363/MealAppeal#readme"
}