【发布时间】:2019-07-09 12:06:24
【问题描述】:
当我从 angular-cli 使用 ng serve 命令时,我的 server.js 没有被执行。当我使用节点服务器时,它工作正常。
server.js:
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path');
const http = require('http');
const api = require('./server/routes/api');
const port = 3000;
const app = express();
app.use(express.static(path.join(__dirname, 'dist/Colab')));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.get('/api', api);
app.get('*', (req,res)=>{
res.sendFile(path.join(__dirname, 'dist/Colab/index.html'));
});
const server = http.createServer(app);
server.listen(port, ()=>console.log(`Server is running on localhost:${port}`));
【问题讨论】:
标签: mean-stack mean