store icon indicating copy to clipboard operation
store copied to clipboard

Property 'forRoot' does not exist on type 'typeof NgReduxModule'

Open paramsingh88 opened this issue 9 years ago • 10 comments

I've created a fresh project using angular cli. Tried using ng2-redux in it. But at the very first place I'm getting this error

ERROR in Error encountered resolving symbol values statically. Calling function 'NgReduxModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /Users/parminder/Documents/code/redux-test/src/app/app.module.ts, resolving symbol AppModule in /Users/parminder/Documents/code/redux-test/src/app/app.module.ts

ERROR in ./src/app/app.module.ts
Module build failed: Error: /Users/parminder/Documents/code/redux-test/src/app/app.module.ts (17,19): Property 'forRoot' does not exist on type 'typeof NgReduxModule'.)
    at _checkDiagnostics (/Users/parminder/Documents/code/redux-test/node_modules/@ngtools/webpack/src/loader.js:116:15)
    at /Users/parminder/Documents/code/redux-test/node_modules/@ngtools/webpack/src/loader.js:141:17
 @ ./src/main.ts 5:0-45
 @ multi main

Here's the code


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgReduxModule, NgRedux } from 'ng2-redux';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    NgReduxModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Straight from the docs, I've been using it. And I'm stuck in this error.

paramsingh88 avatar Dec 27 '16 09:12 paramsingh88

What version of Angular and Ng2 Redux are you using? This API has changed recently

SethDavenport avatar Dec 27 '16 16:12 SethDavenport

If it's a fresh project you'll likely need [email protected]. Then simply remove the .forRoot() part in your code. See the changelog on the feat/v5 branch for details.

SethDavenport avatar Dec 27 '16 16:12 SethDavenport

We'll be releasing v5 soon.

SethDavenport avatar Dec 27 '16 16:12 SethDavenport

I'm using [email protected]. Also, I've tried removing forRoot from there but still I was getting the same error.

Here's a view of my package.json

    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",

paramsingh88 avatar Dec 27 '16 17:12 paramsingh88

@SethDavenport If I remove forRoot, it gives me this error. ERROR in NgReduxModule is not an NgModule

paramsingh88 avatar Dec 27 '16 17:12 paramsingh88

Hmm - that may be related to this: https://github.com/angular/angular-cli/issues/3426#issuecomment-265277988

Still unclear whether that particular message is an ng2-redux issue or an angular-cli issue. Investigating.

SethDavenport avatar Dec 27 '16 18:12 SethDavenport

ERROR in NgReduxModule is not an NgModule: fixed in 5.0.0-beta.2.

SethDavenport avatar Dec 27 '16 19:12 SethDavenport

@SethDavenport i'm still getting the same issue

ERROR in Error encountered resolving symbol values statically. Calling function 'StoreModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /home/touqeer/public_html/podium-client-web/src/app/app.module.ts, resolving symbol AppModule in /home/touqeer/public_html/podium-client-web/src/app/app.module.ts

ERROR in /home/touqeer/public_html/podium-client-web/src/app/app.module.ts (19,17): Property 'forRoot' does not exist on type 'typeof StoreModule'.)

Imports:

imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    StoreModule.forRoot({ user: null }) // <--- 
  ],

touqeershafi avatar Mar 16 '17 08:03 touqeershafi

@touqeershafi Have you figured this out yet? Totally stuck here.

Yugloocamai avatar Jun 21 '17 18:06 Yugloocamai

@Yugloocamai np, for time being i've removed this module.

touqeershafi avatar Jun 22 '17 07:06 touqeershafi