0. ng github-pages:deploy が動かない
ng github-pages:deploy
The specified command github-pages:deploy is invalid. For available options, see `ng help`.
angular-cliを利用してgithub.ioに作ったangularアプリをdeployしたいときに、多分、こういうエラーが出る例が増えて来ていると思う。
angular-cliはこのオプションのサポートをやめたのかもしれない。
その代わり、最近angular-cli-ghpagesというツールが出た。
1. 代わりにangular-cli-ghpagesを使おう!
現在の自分の環境はこういう感じ。
ng --version
@angular/cli: 1.0.0-rc.0
node: 7.7.2
os: darwin x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.9
angular-cli-ghpagesのREADMEに書いてある通りにアプリをビルドして、デプロイしてみた。
ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY/"
angular-cli-ghpages [OPTIONS]
-
Successfully published!
とプロンプトに表示されて、github.ioにアクセスすると、angular2 tutorialで作ったアプリが動いていた。 -
angular-cli-ghpages
の代わりにngh
という短縮コマンドでも使えるようです。こっちの方が楽。 - というわけでこれからは
ngh
ですね。