Torben Van Assche
Torben Van Assche

Reputation: 445

Deployment of angular latest failed on GitHubPages

I am trying to deploy my portfolio for testing onto github pages, but am running into an error that I can't find anything on. I have run the following commands:

  1. npm install -g angular-cli-ghpages
  2. ng build --prod --base-href https://github.com/GrimZero/website.git
  3. ngh

This last command is recognized, but executes with the following error:

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)

UPDATE: I have managed to succesfully publish my page to the web by pushing it via my own source control and setting my github to load that page from the docs folder. I am however running into a few errors upon loading that files cannot be found.

Project: https://github.com/GrimZero/Portfolio

Deployed app: https://grimzero.github.io/Portfolio/

UPDATE2: problem resolved, folder path was wrong on the ng build path

Upvotes: 1

Views: 414

Answers (1)

Miroslav Maksimovic
Miroslav Maksimovic

Reputation: 547

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

I've wrote an article in Medium about deploying angular on github pages.

Please have a look here

Upvotes: 1

Related Questions