添加Angular后app.get()不再响应

时间:2019-03-30 19:49:36

标签: node.js angular

这是app.js,localhost:3000显示

  

哈哈,页面无效

然后添加了一个新的子文件夹angular-src,并在其中保存了所有cli的东西。我还在那里跑过npm installng 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}`);
});

0 个答案:

没有答案