Node.js angular 2文件直接工作,但不通过nodejs express文件

Node.js angular 2文件直接工作,但不通过nodejs express文件,node.js,angular,Node.js,Angular,我正在启动一个MEA2N应用程序,并构建了一个运行在3000端口上的小型express服务器。 angular应用程序在端口4200上运行。如果我打开localhost 3000,我会看到“正在加载…”,因此应用程序不会运行。而如果我打开localhost 4000,我会得到“应用程序工作”。有人知道这是怎么发生的吗 server.js非常标准: // Get dependencies const express = require('express'); const path = requir

我正在启动一个MEA2N应用程序,并构建了一个运行在3000端口上的小型express服务器。 angular应用程序在端口4200上运行。如果我打开localhost 3000,我会看到“正在加载…”,因此应用程序不会运行。而如果我打开localhost 4000,我会得到“应用程序工作”。有人知道这是怎么发生的吗

server.js非常标准:

// Get dependencies
const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');

// Get our API routes
const api = require('./server/routes/api');

const app = express();

// Parsers for POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

// Point static path to dist
app.use(express.static(path.join(__dirname, 'dist')));

// Set our api routes
app.use('/api', api);

// Catch all other routes and return the index file
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, './src/index.html'));
});

/**
 * Get port from environment and store in Express.
 */
const port = process.env.PORT || '3000';
app.set('port', port);

/**
 * Create HTTP server.
 */
const server = http.createServer(app);

/**
 * Listen on provided port, on all network interfaces.
 */
server.listen(port, () => console.log(`API running on localhost:${port}`));
server.js正在根文件夹中运行。
angular app是root/src/indxex.html,如果
server.js
root
文件夹中,angular app在
root/src/index.html

然后

应该是

app.use(express.static(path.join(__dirname, '/src')));

请包括您的文件夹结构和app.js。您完全正确。我已经改变了那个部分,不幸的是仍然没有效果。打开localhost 4200可以工作。打开localhost 3000不起作用not@Mihaly有错误吗?检查chrome developer tools上的网络选项卡,查看是否可以找到index.htmlNo。
app.use(express.static(path.join(__dirname, '/src')));