找不到模块问题reactjs

时间:2019-05-17 19:40:32

标签: javascript node.js reactjs redux

我遇到找不到模块的问题,不确定我缺少什么

./src/reducers/index.js Module not found: Can't resolve './authReducer' in '/Users/guest/Desktop/MERN_APP/app/client/src/reducers'

这是index.js

import { combineReducers } from "redux";
import authReducer from "./authReducer";
import errorReducer from "./errorReducer";
export default combineReducers({
  auth: authReducer,
  errors: errorReducer
});

这是authReducer.js

import { SET_CURRENT_USER, USER_LOADING } from "../actions/types";

const isEmpty = require("is-empty");

const initialState = {
  isAuthenticated: false,
  user: {},
  loading: false
};

export default function(state = initialState, action) {
  switch (action.type) {
    case SET_CURRENT_USER:
      return {
        ...state,
        isAuthenticated: !isEmpty(action.payload),
        user: action.payload
      };
    case USER_LOADING:
      return {
        ...state,
        loading: true
      };
    default:
      return state;
  }
}

这是store.js,这就是所谓的root reducer

import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducers";
const initialState = {};
const middleware = [thunk];
const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(...middleware),
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  )
);
export default store;

文件结构如下

\client store.js \reducers authReducer.js index.js

文件结构应使模块可访问,但不确定是否引起问题。

0 个答案:

没有答案