redux Replit Node.js app Uncaught TypeError:无法读取undefined的属性(阅读“apply”)

cqoc49vn  于 2023-08-05  发布在  Node.js
关注(0)|答案(1)|浏览(290)

回购:https://github.com/jerzy-jarczynski/backend_rest_api_app
我正在尝试在Replit上部署Express.js和React应用程序。该应用程序在localhost上运行良好,我还可以使用以下链接看到它:https://backendrestapiapp.jerzy-jarczynski.repl.co/
但是,当我在隐身选项卡或其他设备上打开它时,我遇到以下错误:

redux.js:621 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
at redux.js:621:18
at e (redux.js:154:12)
at store.js:14:15
at index.js:20:51
at index.js:20:51

字符串
而不是显示应用程序,我看到一个空白屏幕。
我尝试使用以下配置更改.replit文件中的Node.js版本:

run = "nvm install 16.18.0 && nvm use 16.18.0 && node server.js"


我还尝试安装带有--legacy-peer-deps标志的Redux库:

npm install redux react-redux --legacy-peer-deps


在Replit上,Node.js版本更高:

~/backendrestapiapp$ node -v
v18.12.1


所以,我在本地测试了这个版本,但我没有遇到同样的Redux错误。

wbrvyc0a

wbrvyc0a1#

import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';

// import reducers
import concerts from './concertsRedux';
import seats from './seatsRedux';

// combine reducers
const rootReducer = combineReducers({
  concerts,
  seats,
});

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
  rootReducer,
  composeEnhancers(applyMiddleware(thunk))
);

export default store;

字符串
这是正确的store.js,它似乎在Replit上正确工作。

相关问题