未找到Angular runtime-es2015.js

问题描述 投票:0回答:1

当我运行“ ng build”时,我注意到它创建了这样的文件夹结构。

/ dist / projectname /

然后将生成projectname文件夹中的所有文件。

当我运行Angular应用程序时,对于索引文件中的第一个脚本,出现404(未找到)错误。

<body>
  <app-root></app-root>
    <script src="runtime-es2015.js" type="module"></script>
    <script src="runtime-es5.js" nomodule defer></script>
    <script src="polyfills-es5.js" nomodule defer></script>
    <script src="polyfills-es2015.js" type="module"></script>
    <script src="styles-es2015.js" type="module"></script>
    <script src="styles-es5.js" nomodule defer></script>
    <script src="vendor-es2015.js" type="module"></script>
    <script src="vendor-es5.js" nomodule defer></script>
    <script src="main-es2015.js" type="module"></script>
    <script src="main-es5.js" nomodule defer></script>
</body>
  1. 他们应该没有src =“ projectname / runtime-es2015.js”吗?
  2. 如何获得不使用项目名称文件夹进行构建的构建?
  3. 我可以在我的代码中做一些事情来引用projectname文件夹,因为它不假定它吗?

另外,这里是我的server.js文件,因为我觉得这是问题所在。

const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const http = require('http');
const app = express();

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

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

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

app.use('/api', api);

app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, 'dist/clinic-manager/index.html'));
});

// Set Port
const port = process.env.PORT || '3000';
app.set('port', port);

const server = http.createServer(app);

server.listen(port, () => console.log(`Running on localhost:${port}`));

感谢您提供任何帮助!

node.js angular
1个回答
0
投票

我找到了!!

转到angular.json文件,并将“ outputPath”:更改为“ dist”,而不是“ dist / projectname”。

© www.soinside.com 2019 - 2024. All rights reserved.