react-native: Unable to resolve "@storybook/core/manager-api"
Describe the bug I am trying to add storybook on an expo 51 project with expo-router.
To Reproduce Steps to reproduce the behavior:
- I have added the withStorybook in metro.config.js
- I have added the require().default bit on my index.tsx
- When I start without the storybook_enabled envvar, I get this error:
Unable to resolve "@storybook/core/manager-api"
I’ll try to make a repro tomorrow, with 8.3.10.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Code snippets If applicable, add code samples to help explain your problem.
System:
Please paste the results of npx -p @storybook/cli@next sb info here.
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 30 (14 by maintainers)
In Bare React Native 0.76.x, not Expo, it worked fine when I tried the method below.
My Storybook Version:
I’m using PNPM Monorepo + RNX-kit metro-resolver-symlinks. If I don’t use metro-resolver-symlinks, I get an error.
My guess is that RNX-kit metro-resolver-symlinks does not support unstable_enablePackageExports properly.
I’ve tried the same with the Expo App, but I get a different error and am analyzing the cause
Encountered similar issue but not using expo. Followed the manual setup doc as well as the multiple entry points for rn
metro.config.js
After some experimenting I got past this with some advice from @dannyhw . I want to add that I was in a situation where I was including the withStorybook conditionally but it didn’t really work right. Also the resolveRequest override upthread didn’t either. Here is what finally did work:
I am including the other config-decorators in here so you can see how I handled this in the context of others.
this is the critical line that ‘just worked’ for storybook:
trying to conditionally include the withStorybook was less successful than just using the flags.
You need to create a metro config file its required in the setup (see readme).
npx expo customize metro.config.js
See getting started
https://github.com/storybookjs/react-native#getting-started
@hanwenbo please double check your metro is configured correctly, this is an issue with package exports not being enabled when storybook runs.
@OmkarK45 you can do that but thats kinda the whole point of the enabled option, though you can check the source code to see how it works too
https://github.com/storybookjs/react-native/blob/next/packages/react-native/src/metro/withStorybook.ts
Not a lot of code here so you can also just apply the same settings manually if you want.
if
enabled = falsewe just return the config as it was.thanks @dannyhw , i got it working perfectly