简体   繁体   中英

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

I am trying to build an e-commerce store app in React with Moltin JS. Everytime I try to upload it to Heroku, I get a blank page or an error. The error said that it could not resolve "redux-logger". I have tried re-downloading redux logger and also npm install. I still get the same error message. I've also tried NPM update. It works fine when I launch it from my 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; 

The trick is that Heroku installs only production dependencies on deployment by default, so the ones that are listed under dependencies key of you package.json by running npm install --production .

Move dependencies that are crucial to your app running - like redux-logger - from devDependencies to dependencies and that should solve your problem.

devDependencies are meant for things that support you in development, but are not required for the production copy of your app to run, like testing modules, for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM