I built an app on angular 6 and directly able to open index.html from dist folder but when i tried it opening from my node server, error is coming in console as:
Uncaught SyntaxError: Unexpected token <
polyfills.js:1 Uncaught SyntaxError: Unexpected token <
styles.js:1 Uncaught SyntaxError: Unexpected token <
vendor.js:1 Uncaught SyntaxError: Unexpected token <
main.js:1 Uncaught SyntaxError: Unexpected token <
with line 1 as < ! doctype html >
server.js
const express = require('express');
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname,'dist')));
app.get('*',(req,res)=>{
res.sendFile(path.join(__dirname,'dist/ang-node/index.html'));
});
const port = process.env.PORT || 4000;
app.listen(port,(req,res)=>{
console.log(`server started on port ${port} `);
});