简体   繁体   English

迁移到React 16.0.0错误:找不到模块“ react / lib / ReactComponentTreeHook”

[英]Migration to React 16.0.0 Error: Cannot find module “react/lib/ReactComponentTreeHook”

Trying to migrate from react 15.6.1 to 16.0.0 . 尝试从react 15.6.1迁移到16.0.0 I have updated my package.json, to "react": "16.0.0","react-dom": "16.0.0", (only things I changed so far), and from what I've understood from the changelogs, things should have gone smoothly. 我已经将package.json更新为"react": "16.0.0","react-dom": "16.0.0", (仅到目前为止已更改的内容),以及从更改日志中了解的内容,事情应该顺利进行。 But they don't! 但是他们没有! From what I understand, they removed the /lib part in the v16.0.0 , hence why the module cannot be found? 据我了解,他们删除了v16.0.0/lib部分,因此为什么找不到该模块?

Am I missing something obvious? 我是否缺少明显的东西? 在此处输入图片说明 Would appreciate any help! 将不胜感激! :) :)

You probably have two copies of React loaded. 您可能已经加载了两个React副本。
Try this in your terminal: 在您的终端中尝试以下操作:

npm ls react

And also: 并且:

npm ls react-dom

If either of these commands shows more than one result, then you have two copies of React, and that is not supported . 如果这些命令中的任何一个显示了多个结果,则您有两个React副本,并且不受支持

Delete all copies except the ones in the root node_modules , and file an issue with projects that specify React as a dependency . 删除除根node_modules中的所有副本以外的所有副本,并对将React指定为dependency项目提出问题。 It must be a peerDependency so that a situation like this doesn't occur. 必须是peerDependency这样才不会发生这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从“ReactDebugTool.js”中找到模块“react/lib/ReactComponentTreeHook” - Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js' 更新到React 16.2.0时找不到模块“ react / lib / ReactComponentTreeHook”错误 - cannot find module “react/lib/ReactComponentTreeHook” error when updating to React 16.2.0 ReactJS:找不到模块:无法解析'react / lib / ReactComponentTreeHook' - ReactJS: Module not found: Can't resolve 'react/lib/ReactComponentTreeHook' 无法从'ReactTestUtils.js'找到模块'react / lib / React' - Cannot find module 'react/lib/React' from 'ReactTestUtils.js' React NextJS 应用程序,安装 webpack,然后将其删除:错误:找不到模块 'webpack/lib/node/NodeOutputFileSystem' - React NextJS app, installed webpack, then removed it: Error: Cannot find module 'webpack/lib/node/NodeOutputFileSystem' 找不到模块'react-bootstrap/lib/breadcrumb' - Cannot find module 'react-bootstrap/lib/breadcrumb' 创建反应应用程序时出现此错误:找不到模块'./lib/pack.js' - When creating react app this error appears: Cannot find module './lib/pack.js' 找不到模块“反应” - Cannot find module 'react' 反应并要求:错误:找不到模块“。” - React & require: Error: Cannot find module “.” 错误:找不到模块“react-dom” - Error: Cannot find module “react-dom”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM