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
时