我正在尝试部署我的第一个应用程序,该应用程序具有后端的 django 并为前端做出反应(使用 create-react-app)。我遵循了一些教程中的步骤,并设法让我的部署构建运行,但我收到 npm start 错误。我似乎找不到任何解决方案,任何帮助都会受到欢迎。
2021-06-11T21:48:08.784605+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-11T21:48:22.000000+00:00 app[api]: Build succeeded
2021-06-11T21:48:25.830113+00:00 heroku[web.1]: Starting process with command `npm start`
2021-06-11T21:48:28.292792+00:00 app[web.1]:
2021-06-11T21:48:28.292815+00:00 app[web.1]: > [email protected] start /app
2021-06-11T21:48:28.292815+00:00 app[web.1]: > serve -s build
2021-06-11T21:48:28.292815+00:00 app[web.1]:
2021-06-11T21:48:28.297425+00:00 app[web.1]: sh: 1: serve: not found
2021-06-11T21:48:28.304774+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-06-11T21:48:28.305084+00:00 app[web.1]: npm ERR! syscall spawn
2021-06-11T21:48:28.305267+00:00 app[web.1]: npm ERR! file sh
2021-06-11T21:48:28.305429+00:00 app[web.1]: npm ERR! errno ENOENT
2021-06-11T21:48:28.309100+00:00 app[web.1]: npm ERR! [email protected] start: `serve -s build`
2021-06-11T21:48:28.309179+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-06-11T21:48:28.309293+00:00 app[web.1]: npm ERR!
2021-06-11T21:48:28.309384+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-06-11T21:48:28.309470+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-06-11T21:48:28.315822+00:00 app[web.1]:
2021-06-11T21:48:28.316160+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-06-11T21:48:28.316161+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-06-11T21_48_28_310Z-debug.log
2021-06-11T21:48:28.376386+00:00 heroku[web.1]: Process exited with status 1
2021-06-11T21:48:28.543859+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-11T21:50:15.500360+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=taby-bt.herokuapp.com request_id=3c84bb9a-a59b-489c-9d9d-19c886d42c72 fwd="5.15.164.88" dyno= connect= service= status=503 bytes= protocol=http
2021-06-11T21:50:16.200509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taby-bt.herokuapp.com request_id=1d44fdaf-4dcd-4f91-a28f-93e19c3fd9ca fwd="5.15.164.88" dyno= connect= service= status=503 bytes= protocol=http
2021-06-11T21:51:16.423492+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=taby-bt.herokuapp.com request_id=5d78951d-6a1f-45cd-8835-6b52b770e878 fwd="5.15.164.88" dyno= connect= service= status=503 bytes= protocol=http
2021-06-11T21:51:17.062971+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taby-bt.herokuapp.com request_id=d79908e7-f51b-4e69-8563-17aa1aff8792 fwd="5.15.164.88" dyno= connect= service= status=503 bytes= protocol=http
在我的 settings.py 我有这个:
STATIC_URL = '/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR,"build/static")
]
STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
在 package.json 我有这些:
"engines": {
"node": "15.5.1",
"npm": "6.14.11"
}
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"postinstall": "npm run build"
},
我的 Procfile 看起来像这样
release:python manage.py migrate
web:gunicorn chatbot.wsgi --log-file -
该错误表明 heroku 无法启动服务器。
我想你没有安装 gunicorn 包。
并在 settings.py 中
ALLOWED_HOSTS = ["127.0.0.1","localhost","YOUR_APP.herokuapp.com"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句