Hello Guys, How are you all? Hope You all Are Fine. Today After npm start
, the browser gives the error Failed to compile ./src/components/App/App.js Module not found: Can’t resolve ‘react-router-dom’ in reactjs. So Here I am Explaining to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How Module not found: Can’t resolve ‘react-router-dom’ Error Occurs?
Just After npm starts, the browser gives the error:
Failed to compile ./src/components/App/App.js Module not found: Can't resolve 'react-router-dom'.
How To Solve Module not found: Can’t resolve ‘react-router-dom’ Error?
How To Solve Module not found: Can’t resolve ‘react-router-dom’ Error?
To Solve Module not found: Can’t resolve ‘react-router-dom’ Error You Just need to run both commands in your terminal, First of all, Run this command: npm i react-router-dom AND then run this command: npm i @types/react-router-dom Now, Your problem must be solved. Thanks.
Module not found: Can’t resolve ‘react-router-dom’
To Solve Module not found: Can’t resolve ‘react-router-dom’ Error You Just need to install react-router-dom. Just copy the below command and run it in your terminal: npm install react-router-dom –save Now, Your error must be solved. Thanks.
Solution 1: Run this command
You Just need to install react-router-dom. Just copy the Below command and run it in your terminal.
npm install react-router-dom --save
Now, Your error must be solved. Thanks.
Solution 2: Install react-dom
You Just need to run both commands in your terminal, First of all, Run this command.
npm i react-router-dom
AND then run this command.
npm i @types/react-router-dom
Now, Your problem must be solved. Thanks.
Conclusion
It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- How to Download File in React js?
- How to Use .env File in React Project?
- Attempted import error: ‘Redirect’ is not exported from ‘react-router-dom’
- Attempted import error: ‘useHistory’ is not exported from ‘react-router-dom’
- Module not found: Can’t resolve ‘web-vitals’