Angular 8部署到Github页面失败-

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

在我的本地主机上一切正常。

然后我使用ng deploy --base-href=/dentist-angular/将我的应用程序部署到Github Pages。

我的文字应该在每个部分都有一个HTTP错误响应。您应该知道使用NGX翻译将所有文本拉入页面-因此,我认为这是问题的一部分。

我已删除并重新部署,但问题仍然存在。

控制台中的错误消息...

Object { headers: {…}, status: 404, statusText: "Not Found", url: "https://jamesross06000.github.io/assets/i18n/fr.json", ok: false, name: "HttpErrorResponse", message: "Http failure response for https://jamesross06000.github.io/assets/i18n/fr.json: 

这很可能是路径问题,但是当我完全按照安装和部署说明进行操作时,我不确定从这里尝试什么。

HTML ...

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Dentist</title>
    <base href="https://jamesRoss06000.github.io/dentist-angular/">    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <script src="env.js"></script>
      <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="styles.748d964c6c80975e08dc.css"></head>
  <body>
    <app-root></app-root>
  <script src="runtime-es2015.edb2fcf2778e7bf1d426.js" type="module"></script><script src="runtime-es5.edb2fcf2778e7bf1d426.js" nomodule defer></script><script src="polyfills-es5.6696c533341b95a3d617.js" nomodule defer></script><script src="polyfills-es2015.2987770fde9daa1d8a2e.js" type="module"></script><script src="main-es2015.c08ed25e5c5c9aef5a4b.js" type="module"></script><script src="main-es5.c08ed25e5c5c9aef5a4b.js" nomodule defer></script></body>
</html>

仅仅是在GitHub上使用NGX转换是一个很大的禁忌吗?

如果需要查看控制台中记录的错误,这里是Github Pages URL。

这是在控制台日志中重复多次的错误...

ee  @   main-es2015.c08ed25….js:1

这是所创建的dist文件夹中的文件结构...

enter image description here

感谢您的帮助。

angular deployment github-pages angular8 ngx-translate
1个回答
1
投票

我找到了一个解决方案,尽管我没有解释为什么以前不起作用。

要在GitHub页面上构建和部署Angular 8项目,请使用以下方法...

npm install -g angular-cli-ghpages

ng build --prod --base-href "<repo-name>"

ngh --dir dist/<project-name>

以上为我完成了trick俩。

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