Deploy Angular 5 + Nodejs Express app to Heroku

前端 未结 8 1417
清酒与你
清酒与你 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:02

    Correct your code in Server.js

    const express = require('express');
    const app = express();
    const path = require('path');
    
    app.use(express.static(__dirname+'/dist'));
    
    app.listen(process.env.PORT||8080);
    
    
    //Path Location Strategy
    app.get('/', function(req, res) {
      res.sendFile(path.join(__dirname+'/dist/index.html'));
    });
    
    console.log('Console Listening'); 
    

    For future reference -

    try running logs command before hitting the URL.

    $ heroku logs
    

    Then check the logs for further details.

提交回复
热议问题