how to deploy SPA to Heroku?
-
Recently I deployed my SPA project from Github to Heroku. Everything seems right but it built failed.
I used Express as Backend server, and I have set up the script in package.json as:"scripts": { "build": "quasar build", "start": "node server.js", "heroku-postbuild": "cd client && npm install && yarn && yarn build" }
The build log complained that ‘sh: 1: yarn: not found’. I then changed the configs to:
"scripts": { "build": "quasar build", "start": "node server.js", "heroku-postbuild": "cd client && npm install && quasar build" }
but the build logs still complained ‘sh: 1: quasar: not found’. What do I miss? Thank you.
-
Good question. Confusing and missing information.
-
npm install -g @quasar/cli
-
The script section of my SPA on Heroku looks like this:
"scripts": { "build": "quasar build", "start": "node front-end-server.js", "heroku-postbuild": "npm install --only=dev --no-shrinkwrap && npm run build" },
-
@Mickey58 Thank you. By using that exact heroku-postbuild has fixed the deployment issue: quasar not found, thus deployed the SPA successfully.
-
Thank you @Mickey58 … that postbuild script worked for me just as you wrote it.
-
This used to work…until today (February 2, 2021).
I completely removed the heroku-postbuild line and it started working again. -
@jc_71950 - that’s not consistent with my experience.
I still use the above heroku-postbuild: “npm install --only=dev --no-shrinkwrap && npm run build” for Heroku builds and it works perfectly, since about a year.
-
@jc_71950 - today my Heroku build (which has been working successfully until yesterday, with the above statement) failed, with strange dependency related errors. So now I’ve been hit by the same issue like you a few days earlier.
After several unsuccessful attempts to correct it; I removed the above statement…now the Heroku build works again, without that statement. Very strange, not sure what changed at Heroku, NPM, or Quasar, causing that issue.