Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Router 4 Basics Getting Started with React Router Installing React Router and Declaring Routes

olu adesina
olu adesina
23,007 Points

Module not found: Can't resolve 'react-router-dom'

my page wont load correctly keep getting this error

Module not found: Can't resolve 'react-router-dom'

i checked the package.json file and react-dom is there under dependencies

not sure whats going on

Add the json and the code where you are importing it for us to see?

  "name": "course-directory",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "1.0.6"
  "dependencies": {
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-router-dom": "^4.3.1"
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
import React from 'react';
import {
} from 'react-router-dom';

1 Answer

olu adesina
olu adesina
23,007 Points

thanks Brendan Whiting installed react-router-dom separately using npm i react-router-dom command

Thanks, Brendan and Olu. I ran into the same problem and using "rm -rf node_modules" and then "npm i react-router-dom" fixed it for me.