Reactive router cannot resolve module history, lib folder missing

I am creating a new React project and I have a dependency problem between react-routerand history:

ERROR in ./~/react-router/lib/match.js
Module not found: Error: Cannot resolve module 'history/lib/Actions' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/match.js 15:15-45

ERROR in ./~/react-router/lib/useRouterHistory.js
Module not found: Error: Cannot resolve module 'history/lib/useQueries' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/useRouterHistory.js 6:18-51

ERROR in ./~/react-router/lib/createMemoryHistory.js
Module not found: Error: Cannot resolve module 'history/lib/useQueries' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/createMemoryHistory.js 6:18-51

ERROR in ./~/react-router/lib/useRouterHistory.js
Module not found: Error: Cannot resolve module 'history/lib/useBasename' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/useRouterHistory.js 10:19-53

ERROR in ./~/react-router/lib/createMemoryHistory.js
Module not found: Error: Cannot resolve module 'history/lib/useBasename' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/createMemoryHistory.js 10:19-53

ERROR in ./~/react-router/lib/browserHistory.js
Module not found: Error: Cannot resolve module 'history/lib/createBrowserHistory' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/browserHistory.js 5:28-71

ERROR in ./~/react-router/lib/hashHistory.js
Module not found: Error: Cannot resolve module 'history/lib/createHashHistory' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/hashHistory.js 5:25-65

ERROR in ./~/react-router/lib/createMemoryHistory.js
Module not found: Error: Cannot resolve module 'history/lib/createMemoryHistory' in /app/node_modules/react-router/lib
@ ./~/react-router/lib/createMemoryHistory.js 14:27-69

I use the react-routerlatest version 3.0.0, which has history 3.0.0a dependency in my own package.json. I use npmversion 3.10.8, and even if the module is historyinstalled depending on react-router, I added it also to mine package.json, as indicated in react-routerdocs.

Thing react-routersearches for its queries in history/lib/, and the module historyhas its files in the history/(no lib) folder .

/, , , , , .

+4
3

, react-router, history package.json.

history , , react-router, .

react-router >= 3.0, history , react-router:

└─┬ react-router@3.0.0
  └── history@3.2.1

package.json, , .

@ShubhamKhatri , .

+11

npm 3.0.0.

, history, React Router npm freater than 3.0.0.

npm install history, .

+2

,

/lib/createHashHistory

/createHashHistory

HashRouter response-route-dom. HashRouter .

+1

Source: https://habr.com/ru/post/1660165/


All Articles