我正在计算机上运行一个有角度的项目:
Angular CLI:7.1.4 节点:11.6.0 操作系统:Darwin x64 角度:7.1.4
我已将角度从4.5.5更新为7.1.4。
现在,在Chrome浏览器的控制台中出现以下错误:
9 GET http://localhost:3000/runtime.js net :: ERR_ABORTED 404(未找到)
因此它无法在我的index.html中找到脚本(见下文)
但是当我在开发环境中查看我的文件夹时,我可以找到文件,并且路径似乎也正确:
![两个木偶] [1]
我的后端在Node.js中,而app.js文件如下所示:
import pandas as pd
import matplotlib.pyplot as plt
myArray = [(0,0,0,0,0.5,0,0,0,1),(0,0,0,0,0.5,0,0,0,1)]
myColumns = ['col1','col2','col3','co4','col5','col6','col7','col8','col9']
df = pd.DataFrame(myArray,columns=myColumns)
print(df)
ax = df.hist(bins=20)
for x in ax:
for y in x:
y.set_xlim(0,1)
plt.show()
这是我的index.html文件:
const express = require('express');
const router = require('./router'),
templates = require('./views/templates');
// Setup
const app = express();
const port = process.env.PORT || 3000;
router(app);
templates.initSync();
// Start server
app.listen(port, function () {
console.log('Kommis back-end is running on port', port);
});
// Catch unhandled promise rejections, see
// https://nodejs.org/dist/latest- v8.x/docs/api/process.html#process_event_unhandledrejection
process.on('unhandledRejection', (err) => {
console.log(err.stack);
});
module.exports = app;
我意识到我必须添加到基本引用
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Digitaler Tischplan</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.png"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body> <app-root></app-root> <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body> </html>
中,然后它才能起作用!
但是如何更改生成的角度代码的输出以使其起作用,而无需随后对其进行修改?
在进行Angular更新之前,我已经看过了,index.html文件中的脚本是这样写的:
gen/
为什么不再这样做了?
这些是我的angular.json的第一行:
gen/scriptname.js
为了正确构建角度应用程序,我必须在angular-src的
{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "angular-src": { "root": "", "sourceRoot": "src", "projectType": "application", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "../public/gen/", "index": "src/index.html", "main": "src/main.ts", "tsConfig": "src/tsconfig.app.json", "polyfills": "src/polyfills.ts", "assets": [ "src/assets", "src/favicon.ico" ], "styles": [ "src/css/main.scss" ], "scripts": [] },
中的gen/
中。