Stack Overflow Question
Host Provider Heroku doesn't seem to pick up concurrently command in "npm run start". I can get this start command to work with "heroku local web" but get the below log errors when running the same thing on heroku host. I noticed that for some other node full stack projects, the backend is setup to run on startup. In these cases there is routing setup in express so that the request either routes to a backend route or is passed off to a static front endpape. My issues is that I don't have express to support this. I'm just running json-server on the backend (or trying) and my vue.js content on the front.
Is there a work around to get Heroku configured to start both the a front and backend server?
I can run the "npm run start" locally but not on Heroku: It seems like Heroku (at least by default) is configured to start a node app by running "npm run start". As a result, I have the following entry in my package.json:
package.json
"start": "concurrently \"export NODE_ENV=production\" \"json-server --watch db.json\" \"vue-cli-service serve --mode production\""
Heroku Logs:
2021-10-17T18:30:52.000000+00:00 app[api]: Build succeeded
2021-10-17T18:30:54.001782+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-17T18:30:55.002829+00:00 app[web.1]:
2021-10-17T18:30:55.002845+00:00 app[web.1]: > my-vue-app@0.1.0 start /app
2021-10-17T18:30:55.002845+00:00 app[web.1]: > concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"
2021-10-17T18:30:55.002846+00:00 app[web.1]:
2021-10-17T18:30:55.226381+00:00 app[web.1]: [1] /bin/sh: 1: json-server: not found
2021-10-17T18:30:55.227075+00:00 app[web.1]: [2] /bin/sh: 1: vue-cli-service: not found
2021-10-17T18:30:55.228104+00:00 app[web.1]: [2] vue-cli-service serve --mode production exited with code 1272021-10-17T18:30:55.228540+00:00 app[web.1]: [1] json-server --watch db.json exited with code 127
2021-10-17T18:30:55.228781+00:00 app[web.1]: [0] export NODE_ENV=production exited with code 0
2021-10-17T18:30:55.238234+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-17T18:30:55.238413+00:00 app[web.1]: npm ERR! errno 1
2021-10-17T18:30:55.242355+00:00 app[web.1]: npm ERR! my-vue-app@0.1.0 start: `concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"`
2021-10-17T18:30:55.242419+00:00 app[web.1]: npm ERR! Exit status 1
2021-10-17T18:30:55.242477+00:00 app[web.1]: npm ERR!
2021-10-17T18:30:55.242529+00:00 app[web.1]: npm ERR! Failed at the my-vue-app@0.1.0 start script.
2021-10-17T18:30:55.242567+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-17T18:30:55.248113+00:00 app[web.1]:
2021-10-17T18:30:55.248206+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-17T18:30:55.248255+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-10-17T18_30_55_242Z-debug.log
2021-10-17T18:30:55.386385+00:00 heroku[web.1]: Process exited with status 1
2021-10-17T18:30:55.642820+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-17T18:30:59.838564+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myvueapp1.herokuapp.com request_id=eaa81f4f-8d66-4dcc-92e6-5ac730cf9c9c fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:31:00.272840+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myvueapp1.herokuapp.com request_id=a3108da6-5ba3-48cf-8bc4-4b5784a6d171 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:32:51.000000+00:00 app[api]: Build started by user mark.johnson.
2021-10-17T18:33:54.181436+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myvueapp1.herokuapp.com request_id=91cd8f28-f155-4b58-b4ac-bb1539e06413 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:33:54.362762+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myvueapp1.herokuapp.com request_id=8103d63b-9a7d-46f9-b2c1-5d662e77b539 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:34:35.091986+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-17T18:34:34.685663+00:00 app[api]: Deploy 6abb4c8b by user mark.johnson.
2021-10-17T18:34:34.685663+00:00 app[api]: Release v4 created by user mark.johnson.
2021-10-17T18:34:38.788809+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-17T18:34:41.024848+00:00 app[web.1]:
2021-10-17T18:34:41.024866+00:00 app[web.1]: > my-vue-app@0.1.0 start /app
2021-10-17T18:34:41.024866+00:00 app[web.1]: > concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"
2021-10-17T18:34:41.024867+00:00 app[web.1]:
2021-10-17T18:34:41.548998+00:00 app[web.1]: [1] Done
2021-10-17T18:34:41.555274+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555534+00:00 app[web.1]: [1] Resources
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1] http://localhost:3000/table1
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1] http://localhost:3000/table2
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1] Home
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1] http://localhost:3000
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555781+00:00 app[web.1]: [1] Type s + enter at any time to create a snapshot of the database