我一直在尝试将我的angular 2应用程序部署到
github页面,这样我就可以在托管的github链接上查看应用程序,但到目前为止还没有运气.
一旦我完成了我的应用程序,我就运行了这些命令:
ng build --prod git remote add origin "My REPO" git commit -a git push -u origin master
然后我试着在终端上运行
ng github-pages:deploy
并得到此错误:
The specified command github-pages:deploy is invalid. For available options,see `ng help`.
经过研究,我跑过这个页面并按照说明操作:https://www.npmjs.com/package/angular-cli-github-pages
我在项目目录中通过npm安装了angular-cli-github-pages:
npm install --save-dev angular-cli-github-pages
它说我必须创建gh页面,所以我运行以下命令:
git checkout --orphan gh-pages
然后提交文件并推送更改并返回到原始主服务器并运行deploy命令,它给了我同样的错误:
The specified command github-pages:deploy is invalid. For available options,see `ng help`.
解决方法
我最近遇到了同样的问题.在对angular2社区进行了几个小时的搜索之后,我发现在最新的angular-cli版本中已经删除了angular-cli-github-pages模块.要将Angular 2应用程序部署到gh页面,您现在需要安装一个新的npm模块,它与旧的angular-cli-github-pages模块非常相似,但是可以让您比以前的模块做更多的工作.
npm模块是angular-cli-ghpages.您可以在模块的npmjs页面上找到文档和步骤.
希望这对你有所帮助.