Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install redux-logger

I'm trying to install redux-logger by following actions:

npm install --save redux-logger

after that I added import logger to the code:

import logger from 'redux-logger'

and then I included logger to the applyMiddleware:

const createStoreWithMiddleware = applyMiddleware(thunk, logger)(createStore)
const reducer = combineReducers(reducers)
const store = createStoreWithMiddleware(reducer, undefined, autoRehydrate())
persistStore(store, persistConfig)

But I get an error that it's not installed. Does anybody know why it happens?

enter image description here

like image 795
Dmitry Avatar asked Mar 23 '17 12:03

Dmitry


3 Answers

Installation

Be sure that react-native's packager is shut down. npm/yarn will get stuck or most likely show you an error if you don't shut it down while installing new modules.

Configuration

If that's your only middleware, you can do as @Amassuo suggested.

import  createLogger  from 'redux-logger'
const logger = createLogger();
const store = createStore(
    reducers,
    applyMiddleware(logger)
);
like image 59
Alberto Schiabel Avatar answered Sep 29 '22 09:09

Alberto Schiabel


i just used createlogger , gave it no options, it works fine, this will help you Log and debug, until someone figure it out for us ,

import  createLogger  from 'redux-logger'

const logger = createLogger({
    //empty options
});

const store = createStore(
    reducer,
    applyMiddleware(logger)
);
like image 40
Amassuo Avatar answered Sep 29 '22 10:09

Amassuo


Strangely, i did an

npm install 'redux-logger' 

and got the above error. Curious, i visited the redux-logger npm homepage and noticed the latest version was 3.0.6, but the npm default install pulled down ^2.10.2. I solved this by manually specifying 3.0.6 in my package.json and it fixed the issue after an npm install

like image 45
Kermit_ice_tea Avatar answered Sep 29 '22 11:09

Kermit_ice_tea