I've been trying to deploy my angular 2 app to github pages so I can view the app on the hosted github link but no luck so far.
As soon as I finished my app, I ran these commands:
ng build --prod
git remote add origin "My REPO"
git commit -a
git push -u origin master
I then tried to running on terminal
ng github-pages:deploy
and got this error:
The specified command github-pages:deploy is invalid. For available options, see `ng help`.
After researching I ran across this page and followed the instructions: https://www.npmjs.com/package/angular-cli-github-pages
I installed angular-cli-github-pages via npm on my project directory:
npm install --save-dev angular-cli-github-pages
it says I have to create the gh-pages so I ran this command below:
git checkout --orphan gh-pages
and then committed the files and pushed the changes and returned back to the origin master and ran the deploy command and it gave me the same error:
The specified command github-pages:deploy is invalid. For available options, see `ng help`.
I've been going back and forth with different methods and it's not working. Can someone please point what I should do to properly deploy this to github pages?
I faced the same issue recently. After scouring the angular2 community for hours I was able to find that the angular-cli-github-pages module has been removed in the latest angular-cli release. To deploy your Angular 2 apps to gh-pages , you now need to install a new npm module which is quite similar to the older angular-cli-github-pages module but makes you do a little more work that the previous module.
The npm module is angular-cli-ghpages . You can find the documentation and steps on the npmjs page for the module.
Hope this helps you.
I find that the easiest way to deploy to Github Pages is to either use master branch or docs in master branch as the source option in Settings. I go for the docs in master branch option and treat the docs folder as the build directory. It has worked pretty well. I just push to master, Github detects the docs folder and then creates the app/page with its contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With