kodefox / mocha-react-native

6 stars 1 forks source link

Cannot find module 'react/lib/ReactComponentTreeHook' #1

Open META-DREAMER opened 7 years ago

META-DREAMER commented 7 years ago

Trying to use this in my react native project, get the following error:

> mocha --compilers js:mocha-react-native/init --recursive src/**/__tests__/*.test.js

module.js:472
    throw err;
    ^

Error: Cannot find module 'react/lib/ReactComponentTreeHook'
    at Function.Module._resolveFilename (module.js:470:15)
    at Module._load (module.js:418:25)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/node_modules/react-dom/lib/ReactDebugTool.js:16:30)
    at Module._compile (module.js:571:32)
    at Module._extensions..js (module.js:580:10)
    at Object.extensions.(anonymous function) [as .js] (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/register.js:33:14)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Module._load (module.js:439:3)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/node_modules/react-dom/lib/ReactPerf.js:18:22)
    at Module._compile (module.js:571:32)
    at Module._extensions..js (module.js:580:10)
    at Object.extensions.(anonymous function) [as .js] (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/register.js:33:14)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Module._load (module.js:439:3)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/node_modules/react-addons-perf/index.js:1:80)
    at Module._compile (module.js:571:32)
    at Module._extensions..js (module.js:580:10)
    at Object.extensions.(anonymous function) [as .js] (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/register.js:33:14)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Module._load (module.js:439:3)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/node_modules/react-native-mock/build/react-native.js:111:6)
    at Module._compile (module.js:571:32)
    at Object.extensions.(anonymous function) [as .js] (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/register.js:43:17)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Module._load (module.js:439:3)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/node_modules/react-native-mock/mock.js:1:85)
    at Module._compile (module.js:571:32)
    at Object.extensions.(anonymous function) [as .js] (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/register.js:43:17)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Module._load (module.js:439:3)
    at Function.Module._load (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/lib/moduleIntercept.js:64:27)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha-react-native/init.js:7:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha/bin/_mocha:303:3
    at Array.forEach (native)
    at Object.<anonymous> (/Users/hammadjutt/Dev/Covet/NeloNative/node_modules/mocha/bin/_mocha:297:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3
danielsukmana commented 7 years ago

Hi @hammadj. I can't reproduce the error on a fresh project. You can try this first:

If that doesn't solve it, can you post the list of modules that you use from the package.json file?

panpan-lin commented 7 years ago

Could be related to this? https://github.com/facebook/react-native/issues/13390

sibelius commented 7 years ago

"react-test-renderer": "16.0.0-alpha.12", solved my problem

pricetula commented 7 years ago

i have "react-test-renderer": "16.0.0-alpha.12", in my project it still persists

gabceb commented 7 years ago

This issue actually comes from a dep currently talked about at https://github.com/RealOrangeOne/react-native-mock/issues/141. There is hope https://github.com/RealOrangeOne/react-native-mock/pull/151 will fix it

julestruong commented 6 years ago

did someone actually find a fix for this ?

reedyrm commented 6 years ago

Adding react-dom solved this problem for me.

lzapson commented 6 years ago

Actually installing "react-dom": "^16.3.2", resolved the problem!