Jest 失败并出现错误:找不到模块“react/lib/ReactComponentTreeHook" [英] Jest fails with error: Cannot find module 'react/lib/ReactComponentTreeHook'
本文介绍了Jest 失败并出现错误:找不到模块“react/lib/ReactComponentTreeHook"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在我的 React 项目中安装了 Jest v17.0.3.
I have installed Jest v17.0.3 in my react project.
当我在本地运行 jest 时它工作正常,但在构建服务器上它失败了:
When I run jest locally it works fine, but on the build server it fails with:
错误:无法从ReactDebugTool.js"中找到模块react/lib/ReactComponentTreeHook"
Error: Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'
两台机器都运行 node 版本 6.9.1 和 npm 版本 4.0.2.
Both machines are running node version 6.9.1 and npm version 4.0.2.
推荐答案
使用相同版本的 react 和 react-dom.使用此命令后我的问题已解决
use same version of react and react-dom. My problem fixed after using this command
npm install --save react@15.4.0 react-dom@15.4.0
这个问题特别出现在react 15.4.0以上.
this problem specially occurs on react 15.4.0 above.
这篇关于Jest 失败并出现错误:找不到模块“react/lib/ReactComponentTreeHook"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文