electron-userland / electron-forge-templates

Templates bundled with Electron Forge <= 5 to create Electron apps using popular JavaScript frameworks
107 stars 23 forks source link

Angular app-routing causes electron-compile to fail : "Can't stat" #33

Closed nphias closed 5 years ago

nphias commented 7 years ago

I created an electron forge project with template angular 2 i then added an app router to my app-module with an empty path matcher. this causes a fail to compile stat problem where stat is based on a directory not a file.

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

export const routes: Routes = [
  { path: '', redirectTo: '/music', pathMatch: 'full'}
  //{ path: 'lazy', loadChildren: 'app/lazy/lazy.module#LazyModule' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}
Put the console output here

Failed to compile .../src/music: Can't stat ../src/music Error: Can't stat .../src/music at .../node_modules/electron-compile/lib/file-change-cache.js:183:42 at Generator.next () at step (.../node_modules/electron-compile/lib/file-change-cache.js:27:191) at .../node_modules/electron-compile/lib/file-change-cache.js:27:361

What command line arguments are you passing?

none

What does your config.forge data in package.json look like?

unchanged from default

this I suspect will be the experience of others who want to use electron, angular and basic routing

anaisbetts commented 7 years ago

Is ../src/music a real folder that exists? It seems like Angular is trying to do something Clever here.

nphias commented 7 years ago

yes, its a real folder that exists.

ebordon commented 7 years ago

Have you added <base href="./"> in head section of index.html file?

You might need to add <router-outlet></router-outlet> in your appComponent template.

BTW. I had many problems with routes in my electron-forge app and I solved them by updating to the last angular version (currently 4.x.x)

PhoneixS commented 5 years ago

Moved the comment to https://github.com/electron-userland/electron-compile/issues/233#issuecomment-447919791, I think it belongs more to that issue.

malept commented 5 years ago

Closing, see https://github.com/electron-userland/electron-forge-templates/issues/66