开玩笑失败并显示错误:找不到模块'react/lib/ReactComponentTreeHook' [英] Jest fails with error: Cannot find module 'react/lib/ReactComponentTreeHook'

查看:360
本文介绍了开玩笑失败并显示错误:找不到模块'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'

两台机器都运行6.9.1版的节点和4.0.2版的npm.

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

此问题特别发生在以上反应15.4.0上.

this problem specially occurs on react 15.4.0 above.

这篇关于开玩笑失败并显示错误:找不到模块'react/lib/ReactComponentTreeHook'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆