【发布时间】:2020-12-18 22:50:21
【问题描述】:
我正在尝试使用 https://krishnaveer7712.github.io/Reactive-and-Dynamic-Web-Page/ 的 Github 页面发布我的 Angular 项目 https://github.com/KrishnaVeer7712/Reactive-and-Dynamic-Web-Page,但我收到错误 404 Page not found。 当我在 localhost 上打开我的项目时,它工作正常。
我已经完成的步骤:
ng build --prod --base-href /Reactive-and-Dynamic-Web-Page/ 工作正常
gh-pages -d dist(已发布)
我不知道我在哪里做错了,谁能告诉我可能是什么原因。
【问题讨论】:
-
查看这个官方documentation
-
@MiroslavMaksimovic 感谢您的回复,但脚本“npm run build-and-deploy-gh-pages”不起作用,出现错误:“npm ERR!缺少脚本:build-and-deploy-gh-pages'
-
你必须把这个脚本放在你的包 json 脚本数组中:
"build-and-deploy-gh-pages": "ng build --prod --base-href ./ && npx ngh --dir dist/[reponame]"或者在终端中像这样运行它:ng build --prod --base-href ./ && npx ngh --dir dist/[reponame]
标签: angular github angular-cli http-status-code-404 github-pages