我正在尝试将我的产品组合部署到github页面上进行测试,但是遇到了一个我找不到任何东西的错误。我已经运行了以下命令:
npm install -g angular-cli-ghpages
ng build --prod --base-href https://github.com/GrimZero/website.git
ngh
该最后一条命令被识别,但执行时出现以下错误:
Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19) Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
更新:通过将其通过我自己的源控件推送并将其github设置为从docs文件夹加载该页面,我已经成功地将页面发布到了网络上。但是,我在加载文件时遇到了一些错误,找不到文件。
项目:https://github.com/GrimZero/Portfolio
已部署的应用:https://grimzero.github.io/Portfolio/
UPDATE2:问题已解决,ng构建路径上的文件夹路径错误
答案 0 :(得分:0)
Setup:
1.You have an angular project.
2.Install angular-cli-ghpages package from npm like this
'npm install -g angular-cli-ghpages'
3. You can setup npm script like this or run directly in terminal:
"build-and-deploy-gh-pages": "ng build --prod --base-href ./ && npx ngh --dir dist/[reponame]"
Where ./ can be replaced with:
'https://[username].github.io/[reponame]/'
As a matter of fact, in above link you’ll find your github-page.
You’ll be asked for your github username and password to deploy to gihub pages.
This script will create gh-pages branch automatically and setup your repo for publishing online.
Next step would be to to run this script as: 'npm run build-and-deploy-gh-pages
我已经在Medium中撰写了一篇关于在github页面上部署angular的文章。
请看看here