Michael Schlecht
Michael Schlecht

Reputation: 63

Angular 2 build error - '../@angular/platform-browser-dynamic' no exported member 'bootstrap'

I'm getting an error where TypeScript is not recognizing the exported 'bootstrap' function from platform-browser-dynamic.

ERROR in [default] ../retain-app/src/main.ts:1:9 
Module '"../retain-app/node_modules/@angular/platform-browser-dynamic/index"' has no exported member 'bootstrap'.

I imported bootstrap in main.ts like so:

import { bootstrap } from '@angular/platform-browser-dynamic';

This is the dependency in the package.json:

"@angular/platform-browser-dynamic": "^2.0.0",

Any help is appreciated!

Upvotes: 4

Views: 6604

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 208964

Bootstrapping is done a little different with the final version, as opposed to some earlier RCs/betas. We no longer use bootstrap. You should instead import the function platforBrowserDynamic, and load the app module with that function

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './your.app.module.location';

platformBrowserDynamic().bootstrapModule(AppModule);

If you are going off an older tutorial that's not using modules, you may want to just check out the Angular Quickstart. At least the second half (after all the environment setup) where it shows how to use a module.

Upvotes: 12

Related Questions