最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can't install redux-logger - Stack Overflow

programmeradmin6浏览0评论

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 = bineReducers(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?

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 = bineReducers(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?

Share Improve this question edited Jun 5, 2021 at 23:05 Linda Paiste 42.2k8 gold badges79 silver badges116 bronze badges asked Mar 23, 2017 at 12:54 DmitryDmitry 8673 gold badges16 silver badges31 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 6

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)
);

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)
);

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

I got this problem today. Did installation "redux-toolkit", got err. I just reload Visual Studio Code and the problem is gone.

Try to import a property logger from redux-logger (not a whole module):

import {logger} from 'redux-logger'
发布评论

评论列表(0)

  1. 暂无评论