a7dc
a7dc

Reputation: 3426

Heroku: module not found create-react-app

I have a project I am building using create-react-app. When I try to deploy to Heroku, I get the following error:

./src/index.js
Module not found: Can't resolve 'react-redux' in '/app/src'

I thought it was something to do with this but after installing that plugin, I still get the errors.

package.json

{
  "name": "",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.5",
    "react-dom": "^16.8.5",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "case-sensitive-paths-webpack-plugin": "^2.2.0",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1"
  }
}

My Webpack config contains the following line:

isEnvDevelopment && new CaseSensitivePathsPlugin(),

Any ideas?

Upvotes: 1

Views: 464

Answers (1)

Chris
Chris

Reputation: 137228

react-redux and redux itself are listed in your devDependencies so they're not included when you deploy to Heroku. devDependencies are for things you need in development but not in production. Examples might be linters, editor plugins, live reload tools, etc.

You definitely need these to be dependencies, not devDependencies. Move them to that section, update your lock file with npm install or yarn, commit, and deploy again.

I'm not familiar with case-sensitive-paths-webpack-plugin is, but you might need to move that too. (Though it looks like you might only have installed it to try to fix the issue you're asking about. You might be able to just remove it.)

Upvotes: 2

Related Questions