2

In reactJs after run

npm start

it gives

./src/index.js Module not found: Can't resolve 'react' in 'C:\Users...\src'

error.

this is my package.js

{
  "name": "client-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@aspnet/signalr": "^1.0.4",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-scripts": "^1.1.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
Jayani Sumudini
  • 1,409
  • 2
  • 22
  • 29

1 Answers1

5

Try removing package-lock.json, run npm install and then run npm start again.

Dženis H.
  • 7,284
  • 3
  • 25
  • 44
  • I'm happy to hear that. So why isn't my answer accepted? :) – Dženis H. Oct 06 '18 at 02:40
  • 1
    I can accept anser after 4 min,Sure I will accept it.thanks – Jayani Sumudini Oct 06 '18 at 02:42
  • recently I installed node and configured create-react-app, I created one react app and when I am doing npm start it is giving an error "" ./src/index.js Module not found: Can't resolve 'react-dom' in 'C:\Users\Public\Desktop\mytestapp\src'"". then I removed this and again installed it, but the same error is giving again and again. – Monu Kumar Nov 29 '19 at 21:01
  • @MonuKumar Delete `package-lock.json` and the `node_modules` folder. Run `npm update` and then run `npm install` again inside of the `root` folder. Additionally, check if you're using `react-router-dom` and if so, check if that package is listed in your `package.json` file. If you're using it but it's not listed, I suggested installing it separately via `npm i react-router-dom --save`. One important thing, make sure it's `react-router-dom` and not `react-router`. – Dženis H. Nov 30 '19 at 00:42