Angular-cli: Deployment to Github Pages issue: Cannot match any routes

Created on 26 Jan 2018  路  5Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 1.5.5
Node: 8.9.4
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.5
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.38
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.5
@schematics/angular: 0.1.8
typescript: 2.4.2
webpack: 3.8.1

Error: Uncaught (in promise): Error: Cannot match any routes

I'm trying to deploy my Angular SPA app to github pages using this /angular-cli/wiki

I run this command ng build --prod --output-path docs --base-href learningangular

it reroutes my app from https://alamgirqazi.github.io/learningangular to https://alamgirqazi.github.io/learningangular/learningangular/

and I get the above error. I've added more detail here https://stackoverflow.com/questions/48436223/angular-cli-deploy-to-github-pages-issue-error-error-uncaught-in-promise-er#

Here's the link to the app: https://alamgirqazi.github.io/learningangular

devkibuild-angular low inconvenient bufix

Most helpful comment

It's better to change the documentation(https://github.com/angular/angular-cli/wiki/stories-github-pages),
from

ng build --prod --output-path docs --base-href PROJECT_NAME

to

ng build --prod --output-path docs --base-href /PROJECT_NAME/

All 5 comments

Both an absolute and relative URL should work, so I'm not sure why the relative doesn't work in your case. That will need some looking into.

in my case it works with leading/trailing slash in the base-href

ng build --prod --output-path docs --base-href /PROJECT_NAME/

<base href="/PROJECT_NAME/">

It's better to change the documentation(https://github.com/angular/angular-cli/wiki/stories-github-pages),
from

ng build --prod --output-path docs --base-href PROJECT_NAME

to

ng build --prod --output-path docs --base-href /PROJECT_NAME/

This is already fixed in the docs on angular.io. Thanks for pointing this out!

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericel picture ericel  路  3Comments

NCC1701M picture NCC1701M  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

purushottamjha picture purushottamjha  路  3Comments