I'm trying to deploy my Angular SPA app to github pages using this https://github.com/angular/angular-cli/wiki/stories-github-pages .
I run this command ng build --prod --output-path docs --base-href learningangular
learningangular is the name of my github repo.
Here are the routes
const appRoutes: Routes = [
{ path: "", redirectTo: "/abc", pathMatch: "full" },
{ path: "abc", component: OtherComponent },
{ path: "lazy", loadChildren: "./lazymodule/lazy.module#LazyModule" },
{
path: "example",
loadChildren: "./ExampleModule/example.module#ExampleModule"
},
{
path: "projects",
component: ProjectsComponent,
children: [
{
path: "",
component: ErrorPage
},
{
path: ":id",
component: ProjectDetailsComponent
}
]
}
];
when I open github.io/learningangular, it re-routes to github.io/learningangular/learningangular/ and gives the error
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'learningangular'
Error: Cannot match any routes. URL Segment: 'learningangular'
what am I doing wrong?
I'm using
"@angular/core": "^5.0.0",
"@angular/cli": "1.5.0",
"@angular/compiler-cli": "^5.0.0",
You are running the command ng build
with the wrong parameter for --base-href
. It needs a parameter of the following form https://YOUR_GITHUB_USERNAME.github.io/PROJECT_NAME/
.
It seems that the github wiki information is not exact in this case.