I have a Angular 6 application which should be served by a node server running on the port 8080. I have searched and found that adding server.js as below will do the trick, yet I need to change the package.json too. I do not have any clue on how to add server.js as the start on package json file. My project is a complete Angular 6 app. server.js is as below
var express = require('express');
var app = express();
app.use(express.static('app'));
app.get('/', function (req, res,next) {
res.redirect('/');
});
app.listen(8080, 'localhost');
console.log('app is Listening on port 8080');
package.json scripts part is as below,
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
This is the front-end and the back-end runs separately in another node server, which is a node project.
How to run Simple Application with Angular 6 + Node.js & Express; Look here: https://levelup.gitconnected.com/simple-application-with-angular-6-node-js-express-2873304fff0f
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.