How to add script in package.json for deploying multiple localhosts servers in single app in nodejs heroku ?
Suppose in my main project folder I have 2 game folders ( game1 (running on localhost:3000) and game2 (running on localhost:5000) ) and my main website ( running on localhost:8080).
So for running my complete project I perform 1) node server.js
2) node ./game1/server.js
3) node ./game2/server.js
. But while deploying project on heroku we add "start" : "node server.js"
in scripts in package.json . So my question is how to add "node ./game1/server.js "
this also in package.json ?
Asked
Active
Viewed 15 times
0

Pranav Patil
- 127
- 9
-
You can't do this on Heroku. Each app only gets _one_ port. – ChrisGPT was on strike Mar 29 '22 at 17:07
-
See also https://stackoverflow.com/q/7539382/354577 in case you want to deploy to multiple apps – ChrisGPT was on strike Mar 29 '22 at 17:10
-
@Chris i am unable to understand by this link stackoverflow.com/q/7539382/354577 can you plz explain me in short ? – Pranav Patil Mar 29 '22 at 17:20
-
If you really need three servers, deploy them to three apps. That link shows how to deploy a subdirectory to Heroku, e.g. `server.js` to one app, `game1/server.js` to a second, and `game2/server.js` to a third. – ChrisGPT was on strike Mar 29 '22 at 19:35