Search code examples
angulargithubdeploymentgithub-pages

Angular deploy on GitHub Pages


I'm trying to deploy an Angular app to GitHub pages but setting the gh-pages branch as the source shows the content of the README file.

I've tried the official way which is:

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]/

After I run ngh I get this message in terminal:

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-cdv\dist\index.html'
�‍� Uploading via git, please wait...
� Successfully published via angular-cli-ghpages! Have a nice day!

I'm out of ideas on how to solve this. Thanks for any suggestions!


Solution

  • The solution is as follows:

    ng add angular-cli-ghpages
    ng deploy --base-href=https://[username].github.io/[repo]/ --name=[username] --email=[email]