Jest fails with error: Cannot find module 'react/lib/ReactComponentTreeHook'

前端 未结 4 1300
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 13:34

I have installed Jest v17.0.3 in my react project.

When I run jest locally it works fine, but on the build server it fails with:

Error: Cannot fin

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 14:25

    In the latest versions of react we often see this error as we have loaded 2 versions of react:

    To make sure you have just 1 version, run the following in your terminal:

    1. npm ls react-dom

    2. npm ls react

    Both the react and react-dom versions need to be same. If any one of these returns more than 1 version then that's not supported. You have to then correct it in your corresponding package.json

提交回复
热议问题