Unable to install reduction logger

I am trying to install redux-logger with the following steps:

npm install --save redux-logger 

after that I added the import registrar to the code:

 import logger from 'redux-logger' 

and then turned on the registrar in 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 message that it is not installed. Does anyone know why this is happening?

enter image description here

+5
source share
4 answers

Installation

Make sure that the native packer is turned off. npm / yarn will be stuck or most likely will show you an error if you do not disconnect it when installing new modules.

Configuration

If this is your only middleware, you can do what @Amassuo suggested.

 import createLogger from 'redux-logger' const logger = createLogger(); const store = createStore( reducers, applyMiddleware(logger) ); 
+4
source

I just used createlogger, didn’t give it any options, it works fine, it will help you with Log and debug, until someone finds out for us,

 import createLogger from 'redux-logger' const logger = createLogger({ //empty options }); const store = createStore( reducer, applyMiddleware(logger) ); 
+2
source

Try importing the property logger from the reduction logger (not the whole module):

 import {logger} from 'redux-logger' 
0
source

Strange i did

 npm install 'redux-logger' 

and got the above error. Curiously, I visited the redux-logger npm homepage and noticed that the latest version is 3.0.6, but the default installation of npm pulled down ^ 2.10.2. I solved this by manually specifying 3.0.6 in my package.json and fixed the problem after installing npm

0
source

Source: https://habr.com/ru/post/1265824/


All Articles