这是app.js,localhost:3000显示
哈哈,页面无效
然后添加了一个新的子文件夹angular-src
,并在其中保存了所有cli的东西。我还在那里跑过npm install
和ng build
。
const express = require('express')
const bodyParser= require('body-parser')
var path = require('path');
const cors = require('cors');
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));
global.__rootdir = __dirname;
app.get('/', (req, res) =>
{
res.send("haha, invalid page");
})
/* After adding this block, local:3000 won't show haha, it shows content of app.component
const myNgController = require("./controller/myNgController");
app.use('/myNg', myNgController);
*/
const port = 3000;
app.listen(port, () =>
{
console.log(`Server started on port ${port}`);
});