在 github 上部署 angular 11 coreUI 基础应用程序

问题描述

GET https://pazagency.github.io/styles.8bbf607e01fb773556fb.css net::ERR_ABORTED 404
GET https://pazagency.github.io/polyfills-es2015.3c71d2f885223be438aa.js net::ERR_ABORTED 404
GET https://pazagency.github.io/main-es2015.3894bb72f88988ed264b.js net::ERR_ABORTED 404
GET https://pazagency.github.io/runtime-es2015.c17bd2911fc8ca46e6a3.js net::ERR_ABORTED 404

当我在 github 或什至在 Windows 服务器 (IIS) 中部署我的 angular 11 应用程序时,在控制台和应用程序中看到的这些错误在根目录下崩溃。

this is my package.json
    {
  "name": "E-R-P","version": "0.0.0","scripts": {
    "ng": "ng","start": "node server.js","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e","postinstall": "ng build --aot --prod"
  },"private": true,"dependencies": {
    "@angular/animations": "^11.1.0","@angular/cdk": "^11.1.0","@angular/cli": "^11.1.1","@angular/common": "^11.1.0","@angular/compiler": "^11.1.0","@angular/compiler-cli": "^11.1.0","@angular/core": "^11.1.0","@angular/forms": "^11.1.0","@angular/localize": "^11.1.0","@angular/platform-browser": "^11.1.0","@angular/platform-browser-dynamic": "^11.1.0","@angular/router": "^11.1.0","@coreui/angular": "~2.11.1","@coreui/coreui": "^2.1.16","@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1","@coreui/icons": "^2.0.0-rc.0","@coreui/icons-angular": "1.0.0-alpha.3","bootstrap": "^4.6.0","chart.js": "^2.9.4","classlist.js": "^1.1.20150312","core-js": "^3.8.3","express": "^4.17.1","flag-icon-css": "^3.5.0","font-awesome": "^4.7.0","moment": "^2.29.1","ng2-charts": "^2.4.2","ngx-bootstrap": "^6.2.0","ngx-perfect-scrollbar": "^10.1.0","ngx-toastr": "^13.2.0","path": "^0.12.7","rxjs": "^6.6.3","simple-line-icons": "^2.5.5","ts-helpers": "^1.1.2","tslib": "^2.0.0","web-animations-js": "^2.3.2","zone.js": "~0.10.3","typescript": "~4.0.5"
  },"devDependencies": {
    "@angular-devkit/build-angular": "^0.1101.1","@angular/language-service": "^11.1.0","@types/jasmine": "^3.6.3","@types/jasminewd2": "^2.0.8","@types/node": "^14.14.22","codelyzer": "^6.0.0","enhanced-resolve": "^3.3.0","jasmine-core": "~3.6.0","jasmine-spec-reporter": "~5.0.0","karma": "~5.2.0","karma-chrome-launcher": "~3.1.0","karma-coverage": "~2.0.3","karma-jasmine": "~4.0.0","karma-jasmine-html-reporter": "^1.5.0","protractor": "~7.0.0","ts-node": "^8.10.2","tslint": "~6.1.0","typescript": "~4.0.5","express": "^4.17.1"
  },"engines": {
    "node": "14.15.4","npm": "6.14.10"
  }
}
this is my angular.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json","version": 1,"newProjectRoot": "projects","projects": {
    "ng": {
      "root": "","sourceRoot": "src","projectType": "application","architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser","options": {
            "outputPath": "dist/e-r-p","index": "src/index.html","main": "src/main.ts","tsConfig": "src/tsconfig.app.json","polyfills": "src/polyfills.ts","assets": [
              "src/assets"
            ],"styles": [
              "node_modules/@coreui/icons/css/free.css","node_modules/flag-icon-css/css/flag-icon.css","node_modules/font-awesome/css/font-awesome.css","node_modules/simple-line-icons/dist/styles/simple-line-icons.css","node_modules/ngx-toastr/toastr.css","src/scss/style.scss"
            ],"stylePreprocessorOptions": {
              "includePaths": [
                "./node_modules"
              ]
            },"scripts": [],"allowedCommonjsDependencies": [
              "chart.js","classnames"
            ]
          },"configurations": {
            "production": {
              "budgets": [
                {
                  "type": "anyComponentStyle","maximumWarning": "6kb"
                }
              ],"optimization": true,"outputHashing": "all","sourceMap": false,"namedChunks": false,"aot": true,"extractLicenses": true,"vendorChunk": false,"buildOptimizer": true,"fileReplacements": [
                {
                  "replace": "src/environments/environment.ts","with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },"serve": {
          "builder": "@angular-devkit/build-angular:dev-server","options": {
            "browserTarget": "ng:build"
          },"configurations": {
            "production": {
              "browserTarget": "ng:build:production"
            }
          }
        },"extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n","options": {
            "browserTarget": "ng:build"
          }
        },"test": {
          "builder": "@angular-devkit/build-angular:karma","options": {
            "main": "src/test.ts","karmaConfig": "./karma.conf.js","tsConfig": "src/tsconfig.spec.json","assets": [
              "src/assets"
            ]
          }
        },"lint": {
          "builder": "@angular-devkit/build-angular:tslint","options": {
            "tsConfig": [
              "src/tsconfig.app.json","src/tsconfig.spec.json"
            ],"exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },"ng-e2e": {
      "root": "","sourceRoot": "","architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor","options": {
            "protractorConfig": "./protractor.conf.js","devServerTarget": "ng:serve"
          }
        },"options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],"exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },"defaultProject": "ng","schematics": {
    "@schematics/angular:component": {
      "prefix": "app","style": "scss"
    },"@schematics/angular:directive": {
      "prefix": "app"
    }
  },"cli": {
    "analytics": false
  }
}

this is my server.js file
//Install express server
const express = require('express');

const path = require('path');

const app = express();

// Serve only the static files form the dist directory
// app.use('/static',express.static(__dirname + '/dist'));

app.use(express.static(__dirname + '/dist/e-r-p'));

app.get('/*',function(req,res) {
    res.sendFile(path.join(__dirname+'/dist/e-r-p/index.html'));
});

// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);

and this is my index.html
<!doctype html>
<!--
* CoreUI - Free Angular 11 Admin Template
* @version v2.11.1
* @link https://coreui.io/angular/
* copyright (c) 2017-2021 creativeLabs Łukasz Holeczek
* Licensed under MIT (https://coreui.io/license)
-->
<html lang="en">
<head>
  <base href="./">
  <Meta charset="utf-8">
  <Meta http-equiv="X-UA-Compatible" content="IE=edge">
  <Meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  <Meta name="description" content="E-R-P">
  <Meta name="author" content="Hammad Malick">
  <Meta name="keyword" content="Bootstrap,Admin,Template,Free,Angular,Dashboard,Typescript">
    <link rel="icon" type="image/x-icon" href="https://i.imgur.com/RcMTf0O.png">
    <title>E-R-P</title>
  <!-- Global site tag (gtag.js) - Google Analytics -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-118965717-3"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js',new Date());
    // Shared ID
    gtag('config','UA-118965717-3');
    // Angular ID
    gtag('config','UA-118965717-4');
  </script>
</head>
<body class="app">
  <!-- App Loading... -->
</body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)