我正在尝试将 Angular 应用程序部署到 GitHub 页面,但将 gh-pages 分支设置为源显示自述文件的内容。
我已经尝试了官方方式,即:
git checkout -b gh-pages
git push origin gh-pages
npm install -g angular-cli-ghpages
ng build --prod --base-href https://[username].github.io/[repo]/
运行 ngh 后,我在终端中收到此消息:
User@JoseTurron MINGW64 /i/projekt-zaliczeniowy-cdv (gh-pages)
$ ngh
index.html could not be copied to 404.html. This does not look like an angular-cli project?!
(Hint: are you sure that you have setup the directory correctly?)
Diagnostic info: ENOENT: no such file or directory, stat 'I:projekt-zaliczeniowy-cdvdistindex.html'
�� Uploading via git, please wait...
� Successfully published via angular-cli-ghpages! Have a nice day!
我对如何解决这个问题没有想法。感谢您的任何建议!
- 回购:https://github.com/JoseTurron/flight-booking-cdv
- GITHUB页面: https://joseturron.github.io/flight-booking-cdv/
以下是如何将角度应用程序部署到 Github 页面的分步指南。
1) git init
//用于初始化 git 使用 cmd/shell 命中 Enter
2)git add .
//添加 git 中的所有文件
3)git commit -m "first commit"
//提交消息
4)git remote add origin "Your Remote Repository Url"
//连接到 git 存储库
5)git push -u origin master
//推送到 git 存储库
6)npm install -g angular-cli-pages
//安装角度页面以在 github 页面上部署 Angular 项目
7)ng build --prod --base-href="https://Username.github.io/github-Repo/"
//生产构建 ghpages
8*(转到项目文件夹 完成上述步骤后,dist 文件夹将进入 dist>YOurProjectFolder->将所有文件向上移动一级。
9)angular-cli-ghpages
//部署 ghpages
10(转到 GitHub 存储库设置 向下滚动,将有 GitHub 页面和您的公开存储库的链接单击该页面,BOOM Angular 应用程序在 ghPages 上线
解决方案如下:
ng add angular-cli-ghpages
ng deploy --base-href=https://[username].github.io/[repo]/ --name=[username] --email=[email]