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



  • @Jordan

    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.


Log in to reply