通过 GitHub 页面托管 angular 应用程序时出错

errors when hosting the angular application through GitHub pages

当我尝试通过

将我的 angular 应用程序部署到 GitHub 页面时,我遇到了以下错误

angular-cli-ghpages

这些是我在将网站推送到 GitHub

时使用的 bash 命令

ng build --prod --base-href "https://dinith72.github.io/aiesecLoginForm/" - 创建构建版本

ngh --dir dist/AiesecLogin -m "adding request for python serve"

我尝试了上述 git issue posted 中提到的选项,但找不到解决我的问题的方法。 非常感谢您。

我已经使用了 travis-ci,因为它更好,在每次提交时都会自动构建和部署 github 页面,并没有那么复杂,只需添加 travis.yml 并更新angular.json 中的 baseurl for build

像这样:

"baseHref": "https://username.github.io/repo-name/"

以我为例:

"baseHref": "https://malbarmawi.github.io/angular-lessons/"

travis.yml

language: node_js
node_js:
  - "9"
dist: trusty
sudo: false

branches:
  only:
    - master

cache:
  directories:
    - node_modules

install:
  - npm i @angular/cli@6.2.4 -g
  - npm i

script:
  - ng build --prod
deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GITHUB_TOKEN
  local_dir: dist/
  on:
    branch: master

终于得到github token , you can check my project

这篇文章对我有帮助 Deploying your Angular app to GitHub Pages using Travis-CI