Node.js 如何在将CRA部署到Heroku后运行部署后脚本命令?
我有一个create-react应用程序,它在Heroku上构建和部署时没有任何问题。但是,在该应用程序中,我有一个express服务器,部署后需要启动它。到目前为止,我只能让它在Heroku构建的中途启动,这意味着部署停止。我需要在应用程序部署后启动服务器。服务器负责应用程序的webrtc功能 我可以使用heroku后期部署脚本吗 到目前为止,我已尝试将此添加到我的package.json中:Node.js 如何在将CRA部署到Heroku后运行部署后脚本命令?,node.js,express,heroku,create-react-app,Node.js,Express,Heroku,Create React App,我有一个create-react应用程序,它在Heroku上构建和部署时没有任何问题。但是,在该应用程序中,我有一个express服务器,部署后需要启动它。到目前为止,我只能让它在Heroku构建的中途启动,这意味着部署停止。我需要在应用程序部署后启动服务器。服务器负责应用程序的webrtc功能 我可以使用heroku后期部署脚本吗 到目前为止,我已尝试将此添加到我的package.json中: "scripts": { "start": &quo
"scripts": {
"start": "react-scripts start",
"postdeploy": "node ./src/server/index.js",
然后在我的Procfile中将有:
web: npm run postdeploy
但这只是在构建期间运行服务器
部署工作后,从VS code运行
heroku运行节点。/src/server/index.js
,但这意味着每次部署时都必须手动运行它。在包.json
脚本对象中将postdeploy
键更改为heroku postbuild
此命令将在您的构建上载到Heroku后运行