Error message
VM556 angular2-polyfills.js:349Error: Token must be defined!(…)
or
error TS2305: Module \'\"/node_modules/angular2/router\"\' has no exported member \'LocationStrategy\'.
error TS2305: Module \'\"/node_modules/angular2/router\"\' has no exported member \'HashLocationStrategy\'.
error TS2305: Module \'\"/node_modules/angular2/router\"\' has no exported member \'Location\'.
How to fix
update >= rc.5
@NgModule({
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy}]
})
export class AppModule {}
update >= rc.0
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from \'@angular/common\';
import {BrowserPlatformLocation} from \'@angular/platform-browser\';
original
Change
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from \'angular2/router\';
to
import {ROUTER_PROVIDERS} from \'angular2/router\';
import {LocationStrategy, HashLocationStrategy} from \'angular2/platform/common\';
See also
- https://github.com/angular/angular/issues/8229
Full list of moved exports:
- https://github.com/angular/angular/pull/8230/files
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from \'angular2/platform/common\';
import {BrowserPlatformLocation} from \'angular2/src/platform/browser/location/browser_platform_location\';
Another error that\'s commonly caused by this change is
location.createComponent is not a function