Hello, I could use some assistance. I'm currently working on enabling local storage access in Angular 2 with typescript. To achieve this, I've integrated the npm package angular2-localstorage into my project. Initially, I had the "Tour of Heroes" application from angular.io up and running, albeit with minimal styling. Following the guidelines outlined at https://www.npmjs.com/package/angular2-localstorage, I added the recommended code to my app.module.ts file. However, upon attempting to run the application using npm start
, I encountered the following compilation errors:
node_modules/angular2-localstorage/LocalStorageEmitter.ts(46,9): error TS2305: Module '"/Users/joshuaforman/Documents/CodeCraft/a2quickstart/a2-angular/node_modules/@angular/core/src/facade/lang"' has no exported member 'Type'.
node_modules/angular2-localstorage/LocalStorageEmitter.ts(47,9): error TS2305: Module '"/Users/joshuaforman/Documents/CodeCraft/a2quickstart/a2-angular/node_modules/@angular/core/src/di"' has no exported member 'provide'.
You can access all the code for this project here: https://github.com/joshuaforman/angular2-quickstart
Furthermore, below is the complete app.module.ts file that I modified, resulting in the occurrence of these errors:
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
// added for LocalStorage
// followed instructions here: https://www.npmjs.com/package/angular2-localstorage
import { LocalStorageService, LocalStorageSubscriber } from "angular2-localstorage/LocalStorageEmitter";
// Imports for loading & configuring the in-memory web api
import { InMemoryWebApiModule } from "angular2-in-memory-web-api";
import { InMemoryDataService } from "./in-memory-data.service";
import { AppComponent } from "./app.component";
import { HeroDetailComponent } from "./hero-detail.component";
import { HeroesComponent } from "./heroes.component";
import { HeroService } from "./hero.service";
import { DashboardComponent } from "./dashboard.component";
import { routing } from "./app.routing";
@NgModule({
imports: [
BrowserModule,
HttpModule,
InMemoryWebApiModule.forRoot(InMemoryDataService),
FormsModule,
routing
],
declarations: [
AppComponent,
HeroesComponent,
HeroDetailComponent,
DashboardComponent
],
bootstrap: [ AppComponent ],
providers: [
HeroService,
LocalStorageService // added for Local Storage
]
})
export class AppModule {
// added for Local Storage
constructor(storageService: LocalStorageService) {}
}
I've left a comment on each line I added for local storage implementation with the text "LocalStorage". If these three lines are commented out, the compilation and runtime proceed without issues.
Currently, my main goal is to successfully compile the project. Your help is greatly appreciated.
As a newcomer to stack, this is my first question on the platform. Having benefited from the knowledge shared here in the past, I strive to adhere to the community guidelines. Any constructive feedback on how I can improve my queries is welcome.