Storybook: Cannot resolve module 'react/lib/React' in [email protected]

Created on 22 May 2017  路  11Comments  路  Source: storybookjs/storybook

Description:

I am getting Cannot resolve module 'react/lib/React' and many other errors while running storybook in react-native.
Even inside my node_modules/react folder i am not able to find lib folder due to which its showing error.
I am trying to run storybook in react-native latest release candidate 0.45.0-rc.0.
Am i missing something?

Dependencies Version:

    "react-native": "0.45.0-rc.0",
    "react": "16.0.0-alpha.12",
    "@kadira/react-native-storybook": "2.3.0"

Error Trace :

ERROR in ./~/react-dom/lib/ReactMount.js
Module not found: Error: Cannot resolve module 'react/lib/React' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactMount.js 17:12-38

ERROR in ./~/react-dom/lib/ReactMount.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactMount.js 19:24-62

ERROR in ./~/react-dom/lib/findDOMNode.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/findDOMNode.js 15:24-62

ERROR in ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js 15:29-72

ERROR in ./~/react-dom/lib/ReactDOMInvalidARIAHook.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactDOMInvalidARIAHook.js 14:29-72

ERROR in ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js 13:29-72

ERROR in ./~/react-dom/lib/ReactUpdateQueue.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactUpdateQueue.js 15:24-62

ERROR in ./~/react-dom/lib/ReactNodeTypes.js
Module not found: Error: Cannot resolve module 'react/lib/React' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactNodeTypes.js 16:12-38

ERROR in ./~/react-dom/lib/ReactDebugTool.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactDebugTool.js 16:29-72

ERROR in ./~/react-dom/lib/instantiateReactComponent.js
Module not found: Error: Cannot resolve module 'react/lib/getNextDebugID' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/instantiateReactComponent.js 20:21-56

ERROR in ./~/react-dom/lib/ReactDOMOption.js
Module not found: Error: Cannot resolve module 'react/lib/React' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactDOMOption.js 15:12-38

ERROR in ./~/react-dom/lib/ReactMultiChild.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactMultiChild.js 19:24-62

ERROR in ./~/react-dom/lib/ReactCompositeComponent.js
Module not found: Error: Cannot resolve module 'react/lib/React' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactCompositeComponent.js 16:12-38

ERROR in ./~/react-dom/lib/ReactCompositeComponent.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactCompositeComponent.js 18:24-62

ERROR in ./~/react-dom/lib/LinkedValueUtils.js
Module not found: Error: Cannot resolve module 'react/lib/React' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/LinkedValueUtils.js 18:12-38

ERROR in ./~/react-dom/lib/flattenChildren.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/flattenChildren.js 26:27-70 42:33-76

ERROR in ./~/react-dom/lib/ReactChildReconciler.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/ReactChildReconciler.js 29:27-70 37:31-74

ERROR in ./~/react-dom/lib/checkReactTypeSpec.js
Module not found: Error: Cannot resolve module 'react/lib/ReactComponentTreeHook' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/checkReactTypeSpec.js 29:27-70 71:37-80

ERROR in ./~/react-dom/lib/traverseAllChildren.js
Module not found: Error: Cannot resolve module 'react/lib/ReactCurrentOwner' in /Users/ayushnawani/Project/SampleStory/node_modules/react-dom/lib
 @ ./~/react-dom/lib/traverseAllChildren.js 15:24-62
react-native compatibility with other tools

Most helpful comment

Well, i am able to run storybook in react-native after updating dependencies.
I got same error which @pavloko mentioned, so i added react-dom in my dependencies then it worked for me.

   "react": "16.0.0-alpha.12",
   "react-dom": "16.0.0-alpha.12",
   "react-native": "0.45.0-rc.1",
   "@storybook/react-native": "alpha",
   "@storybook/addon-knobs": "^3.0.0-alpha.0",
   "@storybook/addon-options": "^3.0.0-alpha.0",

All 11 comments

If anyone can help, that'd be greatly appreciated!

we too running into same issue, can anyone please guide us on the raised concern.

waiting for resolution

@ndelangen
I try to run on

react-native: "0.36.1"
"react": "~15.3.2"
"@kadira/react-native-storybook": "2.3.0"

react-native-storybook use react-dom: ^15.5.4 that needs react: ^15.5.4
my 'react-native' needs 'react: ^15.3.1"'

If you need a higher version from storybook, the alpha depends on much higher versions:
```json
{
"@storybook/react-native": "alpha"
}

@ndelangen I tried to set the @storybook/react-native to alpha, but I get the following error.

ERROR in ./~/@storybook/ui/dist/modules/ui/routes.js
Module not found: Error: Can't resolve 'react-dom' in '/Projects/work/project_rn/node_modules/react-modal/lib/components'

I can fix the error by manually yarn add react-dom.

@pavloko If you install using the latest @storybook/cli then it adds react-dom automatically for you if you don't have it. We're on the release candidate (rc) releases now, so:

npm i -g @storybook/cli@alpha
cd my-rn-app
getstorybook

Should set up the proper dependencies. Let me know if you have q's about that or run into problems!

Well, i am able to run storybook in react-native after updating dependencies.
I got same error which @pavloko mentioned, so i added react-dom in my dependencies then it worked for me.

   "react": "16.0.0-alpha.12",
   "react-dom": "16.0.0-alpha.12",
   "react-native": "0.45.0-rc.1",
   "@storybook/react-native": "alpha",
   "@storybook/addon-knobs": "^3.0.0-alpha.0",
   "@storybook/addon-options": "^3.0.0-alpha.0",

@ayunawani that was helpful, thank you!

The issue happens when you have differences of major versions between react and react-dom. When upgrading react version, you need to update react-dom also to the latest version.

Use: npm install --save react-dom@latest

npm install --save react-dom@latest
This was a great help! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shilman picture shilman  路  3Comments

levithomason picture levithomason  路  3Comments

arunoda picture arunoda  路  3Comments

sakulstra picture sakulstra  路  3Comments

tomitrescak picture tomitrescak  路  3Comments