Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未找到模块问题_Javascript_Node.js_Reactjs_Redux - Fatal编程技术网

Javascript 未找到模块问题

Javascript 未找到模块问题,javascript,node.js,reactjs,redux,Javascript,Node.js,Reactjs,Redux,我发现模块未找到问题,不确定我缺少了什么 /src/reducers/index.js 未找到模块:无法解析“/Users/guest/Desktop/MERN\u APP/APP/client/src/reducers”中的“/authReducer” 这是index.js import { combineReducers } from "redux"; import authReducer from "./authReducer"; import errorReducer from "./e

我发现模块未找到问题,不确定我缺少了什么

/src/reducers/index.js
未找到模块:无法解析“/Users/guest/Desktop/MERN\u APP/APP/client/src/reducers”中的“/authReducer”

这是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
\还原剂
authReducer.js
index.js


文件结构应使模块可访问,但不确定这是否导致问题

index.js
authReducer.js
是否在同一目录中?是的,它们在同一目录中。当您注释掉
import authReducer from“/authReducer”时,代码是否运行正常和'auth:authReducer,`不,当我从index.js中注释出
import./authReducer
auth:authReducer
时,在“/Users/guest/MERN\u APP/APP/client/src/reducers”中找不到
/src/reducer/index.js”模块:无法解析“/errorReducer”
中的“/errorReducer”
它们在同一个目录中当您注释掉“/authReducer”中的
import authReducer”时,代码是否运行正常
和'auth:authReducer,`不,我在'Users/guest/MERN_APP/APP/client/src/reducer'中找不到
/src/reducers/index.js模块:无法解析'/errorReducer',
当我从index.js中注释出
导入/authReducer
auth:authReducer