Search code examples
angularngrxngrx-storengrx-store-4.0

StoreModule.forFeature does not exist


Im trying to take an existing ngrx Store State and refactor it into sub feature modules.The problem is when I'm using StoreModule.forFeature in my feature modules imports... I get an error during compile:

ERROR in [at-loader] ./src/app/components/login/login.module.ts:67:21
TS2339: Property 'forFeature' does not exist on type 'typeof StoreModule'.

I have actually searched the node_modules/@ngrx/store for "forFeature" which yielded no results. I then re-installed both @ngrx/store & @ngrx/core, still getting no search results for 'forFeature'. I checked the documentation and 'forFeature' is still listed, not depracted, at list in the docs.

The importing statements are as follows:

import {StoreModule} from "@ngrx/store";
import {reducers} from "./rdx/reducers/index"; ...
@NgModule({
imports: [StoreModule.forFeature('loginFeature',reducers)]
...
}

the versions im using o NGRX as shown in the package json are as follows:

"@ngrx/core": "^1.2.0",
"@ngrx/store": "^2.2.3",

Also searched google for this issue with no result. only results for for the depration of "forRoot" to "provideStore" which I already use.


Solution

  • Solved this issue. The problems waere:

    1. that when I installed ngrx it automatically installed the latest of the previous versions of ngrx meaning 2.2.3, to install the really latest I had to use npm install --save @ngrx/store@latest @ngrx/core@latest which installed "@ngrx/store": "^5.2.0"

    2. The documentation of ngrx - in their github documentation they instruct you to specifically install ngrx like so: npm install @ngrx/core @ngrx/[email protected] --save, you can see this in the following link under instalation: https://github.com/ngrx/store