I am going through the Angular2 tutorial at https://angular.io/docs/ts/latest/tutorial/toh-pt5.html. All good to step Routing. Visual Studio Code shows the error at first 03 lines:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms';
as
[ts] Module '"c:/Users/ktran/Source/Repos/angular2-quickstart-ts/node_modules/@angular/core/index"' has no exported member 'NgModule'.
folder node_modules:
any idea please?
An NgModule can export a combination of its own declarations, selected imported classes, and imported NgModules. Don't bother re-exporting pure service modules. Pure service modules don't export declarable classes that another NgModule could use.
Only root application module, AppModule , should import BrowserModule and all other feature module should import CommonModule because we only need the Angular directives in feature module and not the services that are required to launch the app(Which are already available in RootModule).
BrowserModule and CommonModule link BrowserModule imports CommonModule , which contributes many common directives such as ngIf and ngFor .
As Kim Phung stated, this is because a new RC of Angular was just released. Change the following lines in packages.json:
// ...snip... "dependencies": { "@angular/common": "2.0.0-rc.5", "@angular/compiler": "2.0.0-rc.5", "@angular/core": "2.0.0-rc.5", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.5", "@angular/platform-browser": "2.0.0-rc.5", "@angular/platform-browser-dynamic": "2.0.0-rc.5", // ...file continues...
Then run, in your console:
npm update
Good to go!
Some modules just get added to the new version of Angular, so if you are not updating, you can not import it.
After about half an hour of search, got a solution:
Create a new folder and cd to your folder.
In command line, Type:
git clone https://github.com/angular/quickstart cd quickstart npm install
And copy your old code to the newly created project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With