Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Can't resolve '@storybook/addon-ondevice-actions/manager' in React Native #18692

Closed
jsflor opened this issue Jul 12, 2022 · 8 comments

Comments

@jsflor
Copy link
Contributor

jsflor commented Jul 12, 2022

Describe the bug
Getting module not found error when trying to run storybook in react native

./storybook/rn-addons.js:1
Module not found: Can't resolve '@storybook/addon-ondevice-actions/manager'
> 1 | import '@storybook/addon-ondevice-actions/manager';
  2 | import '@storybook/addon-ondevice-knobs/manager';
  3 |
./storybook/rn-addons.js:2
Module not found: Can't resolve '@storybook/addon-ondevice-knobs/manager'
  1 | import '@storybook/addon-ondevice-actions/manager';
> 2 | import '@storybook/addon-ondevice-knobs/manager';
  3 |

To Reproduce
Can't use repro command properly since there is no support of react native yet.
Follow the steps depicted in Storybook get started:

  1. expo init --template tabs@sdk-36 taskbox (Create new empty expo project)

  2. cd taskbox

  3. npx -p @storybook/cli sb init --type react_native (Add storybook support)

  4. export {default} from './storybook'; (Export default from entrypoint of your app)

After setting up the project if you try to run storybook it will crash and you got the error depicted

System

System:
OS: macOS 11.6.1
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 7.16.0 - /usr/local/bin/npm
Browsers:
Chrome: 103.0.5060.114
Firefox: 100.0
Safari: 15.2
npmPackages:
@storybook/addon-actions: ^5.3 => 5.3.21
@storybook/addon-knobs: ^5.3 => 5.3.21
@storybook/addon-links: ^5.3 => 5.3.21
@storybook/addon-ondevice-actions: ^5.3.23 => 5.3.23
@storybook/addon-ondevice-knobs: ^5.3.25 => 5.3.25
@storybook/react-native: ^5.3.25 => 5.3.25

Additional context
Screenshot 2022-07-12 at 13 54 50

@retyui
Copy link

retyui commented Jul 12, 2022

Fix:

-import '@storybook/addon-ondevice-actions/manager';
-import '@storybook/addon-ondevice-knobs/manager';
+import '@storybook/addon-ondevice-actions/register';
+import '@storybook/addon-ondevice-knobs/register';

@designorant
Copy link

Thanks @jsflor & @retyui!

Somewhat related question: shouldn't the standard imports be updated too?

I'm getting:

ERROR in ./storybook/addons.js
Module not found: Error: Can't resolve '@storybook/addon-actions/manager' in '/my-app/storybook'

Changing manager to register helps with the errors indeed but I can't seem to get the stories to load nevertheless.

@jsflor
Copy link
Contributor Author

jsflor commented Jul 14, 2022

@designorant I got it changing only the ./storybook/rn-addons.js imports but checked the sources of ./storybook/addons.js imports and they also should be updated:

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-knobs/register';

Did you export StorybookUIRoot from the entry point of you app?

@designorant
Copy link

@jsflor Yes, thanks, I did. I see Storybook in iOS Simulator just fine, but the web version via yarn storybook doesn't pick up the stories at all. Apparently this is a known issue but issues like this one makes me wonder whether Storybook in RN is a niche. Clearly there's quite a few things that just don't work.

Interestingly, when following the tutorial via Expo, yarn storybook still doesn't load stories, the Expo Web View works fine, but the Expo iOS Sim doesn't. Bit of a mix and match experience!

@designorant
Copy link

designorant commented Jul 14, 2022

@shilman Looks like this got closed despite more updates needed in addons.js. Not sure whether it's something that behaves differently in v5 and v6 though so just leaving it here for any future Internet wanderers.

@shilman shilman reopened this Jul 14, 2022
@shilman
Copy link
Member

shilman commented Jul 25, 2022

Ermahgerd!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.16 containing PR #18693 that references this issue. Upgrade today to the @future NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jul 25, 2022
@shilman
Copy link
Member

shilman commented Jul 26, 2022

Zoinks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.10-alpha.0 containing PR #18693 that references this issue. Upgrade today to the @prerelease NPM tag to try it out!

npx sb upgrade --prerelease

@shilman
Copy link
Member

shilman commented Aug 4, 2022

Yippee!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.10 containing PR #18693 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants