angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

@angular/router/index"' has no exported mng 'Routes'

Open a5hik opened this issue 10 years ago • 7 comments

angular-cli: 1.0.0-beta.6 node: 6.2.1 os: darwin x64

I have updated the angular cli from version beta.5 to beta.6, after that the ng build is failing with the below err.

@angular/router/index"' has no exported mng 'Routes'

I have my routers generated using cli beta.5.

I suspect the problem with the @Routes annotation.

the routes are generated with the @Routes like below.

@Routes([
  {path: '/login', component: LoginComponent},
  {path: '/dashboard', component: DashboardComponent},
 ])

a5hik avatar Jun 22 '16 11:06 a5hik

Yeah same thing happened with me.

This is what i did - added a new file, you can call it routes.ts

import {provideRouter, RouterConfig} from '@angular/router';
import {ItemListComponent} from "./item-list/item-list.component";
import {ItemDetailComponent} from "./item-detail/item-detail.component";

export const routes:RouterConfig = [
    {path: 'item/:action/:id', component: ItemDetailComponent},
    {path: 'item/:action', component: ItemDetailComponent},
    {path: 'items', component: ItemListComponent},
    {path: '', redirectTo: 'items', terminal: true},
];

export const APP_ROUTER_PROVIDERS = [
    provideRouter(routes)
];

modified my main.ts file:

import {APP_ROUTER_PROVIDERS} from './app/routes';

bootstrap(AppComponent, [
    APP_ROUTER_PROVIDERS
])
.catch(err => console.error(err));;

hassanasad avatar Jun 22 '16 13:06 hassanasad

Yes, done the same thing provided here.. https://angular.io/docs/ts/latest/guide/router.html

had to do it manually.

a5hik avatar Jun 22 '16 13:06 a5hik

I'm closing this as obsolete for now due to the CLI having route generation disabled. At the moment we're still waiting for style guide recommendations for the new Router.

filipesilva avatar Jul 04 '16 01:07 filipesilva

@hassanasad, if you still have that issue, this might help:

import {APP_ROUTER_PROVIDERS} from './app/routes';

bootstrap(AppComponent, [
    ...APP_ROUTER_PROVIDERS
])
.catch(err => console.error(err));

danielmhair avatar Jul 06 '16 05:07 danielmhair

Hi,

I tried following this but i'm getting the error below traceur 404

i'm using angular-cli: 1.0.0-beta.10

in my ./app/app.routes.ts

` import { provideRouter, RouterConfig } from '@angular/router'; import { WelcomeComponent } from './home/welcome.component';

export const routes:RouterConfig = [ { path: '/welcome', component: WelcomeComponent } ]

export const APP_ROUTER_PROVIDERS = [ provideRouter(routes) ] `

and in my main.ts

`import { bootstrap } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { AppComponent, environment, APP_ROUTER_PROVIDERS } from './app/';

if (environment.production) { enableProdMode(); }

bootstrap(AppComponent, [ APP_ROUTER_PROVIDERS ]).catch(err => console.error(err));`

Any advice on how to resolve?

Thanks

zone.js:101 GET http://localhost:4200/traceur 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:336Zone.scheduleMacroTask @ zone.js:273(anonymous function) @ zone.js:122send @ VM7303:3fetchTextFromURL @ system.src.js:1154(anonymous function) @ system.src.js:1735ZoneAwarePromise @ zone.js:584(anonymous function) @ system.src.js:1734(anonymous function) @ system.src.js:2759(anonymous function) @ system.src.js:3333(anonymous function) @ system.src.js:3600(anonymous function) @ system.src.js:3985(anonymous function) @ system.src.js:4448(anonymous function) @ system.src.js:4700(anonymous function) @ system.src.js:406ZoneDelegate.invoke @ zone.js:323Zone.run @ zone.js:216(anonymous function) @ zone.js:571ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426 zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/traceur at XMLHttpRequest.wrapFn as _onreadystatechange at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38) at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48) at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34) Error loading http://localhost:4200/traceur Error loading http://localhost:4200/app/app.routes.js as "./app.routes" from http://localhost:4200/app/index.js ; Zone: ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/traceur(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/traceur(…)

ajmebc avatar Aug 12 '16 10:08 ajmebc

RouterConfig don't work anymore use Routes

muhammadumerfarooq avatar Jan 28 '18 17:01 muhammadumerfarooq

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.