Deploy Angular 5 + Nodejs Express app to Heroku

前端 未结 8 1408
清酒与你
清酒与你 2021-02-04 02:35

I have an Angular 5 App.

This is what I have in my package.json

{
  "name": "web",
  "version": "0.0.0&         


        
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 03:21

    Here's how I make my Angular app to deploy and work on Heroku:

    1. Your server.js should look something like this: https://hastebin.com/zavehahide.js
    2. In your package.json, move @angular/cli and @angular/compiler-cli from devDependencies to dependencies
    3. Also in your package.json, add postinstall: ng build --prod and start: node server.js to scripts

    You should be good to go.

提交回复
热议问题