gpt4 book ai didi

部署后 Angular 代码未在服务器上运行

转载 作者:行者123 更新时间:2023-11-28 23:10:38 25 4
gpt4 key购买 nike

我正在使用 angular 8

当我使用“ng build”或“ng build --prod true”在本地构建我的项目时,它工作正常。

   local URL is http://localhost:4200/apw/

但是当我在服务器上部署我的代码时(服务器正在使用 maven angular 插件来构建和部署代码),它不起作用(就像我使用 tomcat 服务器运行构建时一样)并在 https://ciigate.apexxfintech.com/apw/ 上运行代码

它在控制台中显示错误,无法找到主要文件,如 main.js、pollyfills.ts、runtime.js 等。所以在 https://ciigate.apexxfintech.com/apw/ 上什么也没有显示

enter image description here

这是我的index.html

 <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Apexx Portal</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="//netdna.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<!-- material icons import-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body style="margin: 0px">
<app-root></app-root>
</body>
</html>

如果您需要任何其他信息,请告诉我

最佳答案

我认为您收到的错误是因为您没有像这样在 angular.json 文件中定义正确的路径:

示例 Angular.JSON 片段

"options": {
"outputPath": "dist",
"index": "src/index.html", //Define your main,runtime,polyfills routes here
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico",
"src/manifest.webmanifest"
],
"styles": [
"src/styles.css",
"node_modules/bootstrap/scss/bootstrap.scss",
"src/assets/scss/paper-dashboard.scss",
"node_modules/ngx-toastr/toastr.css",
"node_modules/bootstrap/dist/css/bootstrap.css",
"node_modules/font-awesome/css/font-awesome.min.css"
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.js"
]
},

更新文件后再次执行 build --prod 然后部署它。

关于部署后 Angular 代码未在服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58521615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com