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

前端 未结 4 1341
爱一瞬间的悲伤
爱一瞬间的悲伤 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:23

    Can you check which version of React you are using? Is it the same on both servers? I would try removing node_modules and reinstalling the dependencies. The reason I am suggesting this is that in React v15.4.0 you cannot import private apis and it seems that ReactDebugTools.js is trying to import from react/lib/....

    From the blogpost about React v15.4.0 (Link):

    However, there is a possibility that you imported private APIs from react/lib/*, or that a package you rely on might use them. We would like to remind you that this was never supported, and that your apps should not rely on internal APIs. The React internals will keep changing as we work to make React better.

    Hope this helps!

提交回复
热议问题