storybook: [Bug]: Can't import various packages in Expo 53+
Describe the bug
After upgrading to Expo 53, storybook no longer is able to render most of my stories.
They fail with The requested module '/node_modules/react-native-web/node_modules/@react-native/normalize-colors/index.js?v=6b1f23ba' does not provide an export named 'default' error.
Interestingly, they work in build mode.
I managed to build a simple repro that uses just expo, storybook and @expo/html-elements that triggers the error. (Without the @expo/html-elements package, the problem doesn’t appear. But as that package has zero dependencies, I doubt it’s the cause; it’s rather just one of many ways of triggering the error.)
Reproduction link
https://github.com/fullstackhouse/expo-storybook-demo
Reproduction steps
From my GH repro:
git clone fullstackhouse/expo-storybook-demo
cd expo-storybook-demo
yarn storybook
# open `Example/Header` story to see the error
Or, alternatively from scratch:
npx create-expo-stack@latest // create an expo app
npm create storybook@latest // add storybook
npm install --save @expo/html-elements //
vi stories/Header/Header.tsx // make it use some component from `@expo/html-elements`
yarn storybook
System
Storybook Environment Info:
System:
OS: macOS 15.3.2
CPU: (8) arm64 Apple M1
Shell: 3.6.1 - /usr/local/bin/fish
Binaries:
Node: 22.13.0 - ~/.nodenv/versions/22.13.0/bin/node
Yarn: 1.22.22 - ~/.nodenv/versions/22.13.0/bin/yarn <----- active
npm: 11.3.0 - ~/.nodenv/versions/22.13.0/bin/npm
Browsers:
Chrome: 135.0.7049.115
Safari: 18.3.1
npmPackages:
@storybook/addon-essentials: ^8.6.12 => 8.6.12
@storybook/addon-interactions: ^8.6.12 => 8.6.12
@storybook/addon-onboarding: ^8.6.12 => 8.6.12
@storybook/blocks: ^8.6.12 => 8.6.12
@storybook/react: ^8.6.12 => 8.6.12
@storybook/react-native-web-vite: ^8.6.12 => 8.6.12
@storybook/test: ^8.6.12 => 8.6.12
eslint-plugin-storybook: ^0.12.0 => 0.12.0
storybook: ^8.6.12 => 8.6.12
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 17 (9 by maintainers)
** Disclaimer** This information might be inaccurate, due to it being generated automatically This appears to be an issue with how react-native-web is being bundled by Vite in development mode. To resolve: 1. Add a Vite alias in your
.storybook/main.ts:ts export default { viteFinal: async (config) => { return { ...config, resolve: { ...config.resolve, alias: { ...config.resolve?.alias, 'react-native-web': 'react-native-web/dist/index.js', '@react-native/normalize-colors': '@react-native/normalize-colors/lib/index.js' } } }; } };2. Ensure react-native-web is listed as a direct dependency rather than a transitive one:json { "dependencies": { "react-native-web": "^0.19.0" } }About Greptile
This response provides a starting point for your research, not a precise solution.
Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
Edit Issue Bot Settings · Greptile