Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 821
Michael Schlecht Avatar asked Dec 15 '22 03:12

Michael Schlecht


1 Answers

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.

like image 57
Paul Samsotha Avatar answered Dec 18 '22 12:12

Paul Samsotha