angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open paramsingh88 opened this issue 9 years ago • 6 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

"forRoot" has been remove in 5.0 beta.0 (which is required if using latest angular). See: https://github.com/angular-redux/ng2-redux/blob/feat/v5/CHANGELOG.md

clydin avatar Dec 27 '16 14:12 clydin

after applying as described in the latest CHANGELOG, I'm getting this error: "NgReduxModule is not an NgModule". this is the updated code:

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

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

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

what else do I miss here?

ronenl avatar Dec 27 '16 15:12 ronenl

@ronenl that usually indicates an angular version mismatch between a library and the app

clydin avatar Dec 27 '16 20:12 clydin

The fix for the same has been made in 5.0.0-beta.2

paramsingh88 avatar Dec 28 '16 06:12 paramsingh88

Thanks! indeed the problem was solved in 5.0.0-beta.2

ronenl avatar Dec 28 '16 12:12 ronenl

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.