Definitelytyped: [ts] 安装@types/react-router-dom 后找不到模块“react”

创建于 2017-06-28  ·  3评论  ·  资料来源: DefinitelyTyped/DefinitelyTyped

  • [x ] 我尝试使用@types/xxxx包但遇到了问题。
  • [ ] 我尝试使用最新的稳定版 tsc。 https://www.npmjs.com/package/typescript
  • [] 我有一个不适合StackOverflow 的问题。 (请在那里提出任何适当的问题)。
  • [ ] [提及](https://github.com/blog/821-mention-somebody-they-re-notified) 作者(见Definitions by:中的index.d.ts )以便他们可以回复.

    • 作者:@....

你好@tkrotoff @huy-nguyen

我刚刚安装了@types/react-router-dom。 我的项目无法再识别 React 和 React-dom。
请参阅下面的 package.json。

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"
  }
}

有什么想法吗?

谢谢

最有用的评论

删除 node_modules 目录,关闭编辑器,npm install/yarn,等待,重新打开编辑器

所有3条评论

删除 node_modules 目录,关闭编辑器,npm install/yarn,等待,重新打开编辑器

虽然现在它找不到 Node 模块“process”或“require”,但修复了它,但它们可能是因为我升级了 TypeScript。

将记录不同的问题

我刚刚遇到了这个问题。 首先确保您的 node_modules 存在。 如果是,删除它并运行 npm i 或 yarn install。 还要确保您的节点包管理器在 v11.0.0 上。 它推荐用于反应

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jamespero picture jamespero  ·  3评论

variousauthors picture variousauthors  ·  3评论

fasatrix picture fasatrix  ·  3评论

victor-guoyu picture victor-guoyu  ·  3评论

Loghorn picture Loghorn  ·  3评论