Upon running webpack for my project, an error regarding the React-Redux package not being able to resolve some of its internal modules has been encountered:
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './components/Context' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 3:0-57 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './components/Provider' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 1:0-45 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './components/connectAdvanced' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 2:0-59 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './connect/connect' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 4:0-40 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './hooks/useDispatch' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 5:0-70 12:0-179 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './hooks/useSelector' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 6:0-70 12:0-179 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './hooks/useStore' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 7:0-61 12:0-179 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './utils/batch' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 8:0-41 11:0-8
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './utils/reactBatchedUpdates' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 9:0-79 11:9-14 12:0-179
@ ./index.tsx
ERROR in ./node_modules/react-redux/es/index.js
Module not found: Error: Can't resolve './utils/shallowEqual' in '/home/.../frontend/src/node_modules/react-redux/es'
@ ./node_modules/react-redux/es/index.js 10:0-48 12:0-179
@ ./index.tsx
Is there any way to resolve this issue? Could it be due to the installation of react-redux before redux? If so, how can this be resolved? Attempts such as deleting package-lock.json
, removing node_modules
, and reinstalling using npm install
were made. Additionally, upon inspecting the filesystem, it was found that the unresolved modules do exist on the filesystem; for example, even though ./components/Provider
cannot be resolved by webpack, the file
node_modules/react-redux/es/Provider.js
is present and intact.
Here is the relevant section from package.json
. Could a version mismatch be causing this problem?
"devDependencies": {
"@types/classnames": "^2.2.9",
"@types/react": "^16.9.9",
"@types/react-dom": "^16.9.1",
"@types/react-redux": "^7.1.5",
"@types/redux": "^3.6.0",
"@typescript-eslint/eslint-plugin": "^2.4.0",
"@typescript-eslint/parser": "^2.4.0",
"eslint": "^6.5.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^1.7.0",
"prop-types": "^15.7.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"source-map-loader": "^0.2.4",
"ts-loader": "^6.2.0",
"typescript": "^3.6.4",
"typescript-eslint": "0.0.1-alpha.0",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
},
"dependencies": {}