当我尝试将电子商务应用程序上传到 Heroku 时出现 redux 记录器错误

I am getting a redux logger error when I try to upload an ecommerce app to Heroku

我正在尝试使用 Moltin JS 在 React 中构建一个电子商务商店应用程序。每次我尝试将其上传到 Heroku 时,都会出现空白页面或错误。该错误表示无法解析 "redux-logger"。我试过重新下载 redux logger 和 npm install。我仍然收到相同的错误消息。我也试过 NPM 更新。当我从 VS Code 启动它时,它工作正常。
github docs Heroku Page

// import the ability to modify browser history within our router
import createHistory from 'history/createBrowserHistory';

// import our logger for redux
import { createLogger } from 'redux-logger';

// import a library to handle async with redux
import thunk from 'redux-thunk';

// import the redux parts needed to start our store
import { createStore, applyMiddleware, compose } from 'redux';

// import the middleware for using react router with redux
import { routerMiddleware } from 'react-router-redux';

// import the already combined reducers for redux to use
import rootReducer from './ducks';

// import moltin API wrapper for use with Redux
import * as api from './moltin';

// create and export history for router
export const history = createHistory();

// combine the middlewares we're using into a constant so that it can be used by our store
const middleware = [thunk.withExtraArgument(api), routerMiddleware(history)];

// declare any enhancers here
const enhancers = [];

// use Redux devtools if available in development
if (process.env.NODE_ENV === 'development') {
  const devToolsExtension = window.devToolsExtension;

  if (typeof devToolsExtension === 'function') {
    enhancers.push(devToolsExtension());
  }

  middleware.push(createLogger());
}

// compose our middleware
const composedEnhancers = compose(applyMiddleware(...middleware), ...enhancers);

// create our redux store using our reducers and our middleware, and export it for use in index.js
const store = createStore(rootReducer, composedEnhancers);

export default store;

诀窍是 Heroku 默认情况下只安装部署的生产依赖项,因此 dependencies 键下列出的那些 package.json by 运行ning npm install --production.

将对您的应用 运行ning 至关重要的依赖项(如 redux-logger)从 devDependencies 移动到 dependencies,这应该可以解决您的问题。

devDependencies 用于在开发过程中支持您的事情,但对于将您的应用程序复制到 运行 的生产副本来说并不是必需的,例如测试模块。