Definitelytyped: [ts] Cannot find module 'react' after installling @types/react-router-dom

Created on 28 Jun 2017  ·  3Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

  • [x ] I tried using the @types/xxxx package and had problems.
  • [ ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [ ] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [ ] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @....

Hello @tkrotoff @huy-nguyen

I just installed @types/react-router-dom. My project can no longer recongize React and React-dom.
See package.json below.

image

{
  "name": "responder",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@types/jest": "^20.0.2",
    "@types/node": "^8.0.5",
    "@types/react": "^15.0.33",
    "@types/react-dom": "^15.5.1",
    "@types/react-router-dom": "^4.0.5",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.1.1",
    "react-scripts-ts": "2.3.2"
  },
  "devDependencies": {
    "typescript": "^2.4.1"
  },
  "scripts": {
    "start": "react-scripts-ts start",
    "build": "react-scripts-ts build",
    "test": "react-scripts-ts test --env=jsdom",
    "eject": "react-scripts-ts eject"
  }
}

Any idea there?

Thanks

Most helpful comment

Delete node_modules directory, close your editor, npm install/yarn, wait, reopen your editor

All 3 comments

Delete node_modules directory, close your editor, npm install/yarn, wait, reopen your editor

That fixed it although now it cannot find Node modules 'process' or 'require' but they may be because I upgraded TypeScript.

Will log different issue

I just experienced this problem. First make sure your node_modules is present. Incase it is, delete it and run npm i or yarn install. Also make sure your node package manager is on v11.0.0. its recommended for react

Was this page helpful?
0 / 5 - 0 ratings