storybook: [Bug]: error Unable to resolve module storybook/internal/preview-api
Describe the bug
cannot run react-native with latests versions
error Unable to resolve module storybook/internal/preview-api from /Users/alain/myproject/node_modules/@storybook/addon-actions/dist/preview.js: storybook/internal/preview-api could not be found within the project or in these directories:
node_modules
2 |
3 | var uuid = require('uuid');
> 4 | var previewApi = require('storybook/internal/preview-api');
| ^
5 | var global = require('@storybook/global');
6 | var previewErrors = require('storybook/internal/preview-errors');
7 |.
versions used
"react-native": "0.74.3",
"@storybook/addon-actions": "^8.2.9",
"@storybook/addon-ondevice-actions": "^7.6.20",
"@storybook/addon-ondevice-controls": "^7.6.20",
"@storybook/addon-themes": "^8.2.9",
"@storybook/preview-api": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/react-native": "^7.6.20",
"@storybook/react-native-theming": "^7.6.20",
project was running with this previous following versions but storybook stopped working few month ago since i udpate react-native itself. it stuck on splascreen most of the time
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-ondevice-actions": "^7.6.15",
"@storybook/addon-ondevice-controls": "^7.6.15",
"@storybook/addon-themes": "^7.6.17",
"@storybook/react": "^7.6.17",
"@storybook/react-native": "^7.6.15",
"@storybook/react-native-theming": "^7.6.15",
Reproduction link
nolink.com
Reproduction steps
just try to run project
System
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M2 Pro
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.6.0 - /opt/homebrew/bin/node
Yarn: 4.2.1 - /usr/local/bin/yarn <----- active
npm: 10.8.2 - /opt/homebrew/bin/npm
Browsers:
Chrome: 127.0.6533.120
Safari: 17.6
npmPackages:
@storybook/addon-actions: ^8.2.9 => 8.2.9
@storybook/addon-ondevice-actions: ^7.6.20 => 7.6.20
@storybook/addon-ondevice-controls: ^7.6.20 => 7.6.20
@storybook/addon-themes: ^8.2.9 => 8.2.9
@storybook/preview-api: ^8.2.9 => 8.2.9
@storybook/react: ^8.2.9 => 8.2.9
@storybook/react-native: ^7.6.20 => 7.6.20
@storybook/react-native-theming: ^7.6.20 => 7.6.20
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 7
- Comments: 19 (11 by maintainers)
Looks like we are using a very old version of Jest that doesn’t support package.json export rewriting - https://github.com/jestjs/jest/issues/9771 I attempted to set
moduleNameMapperandtransformIgnorePatternsin thejest.config.js(orconfig-overrides.js) file but it looks like I need to upgrade Jest first.Ah in that case that would be expected if the storybook package is not installed i think it’s not needed
As mentioned previously by @shilman , we’ve solved this error by adding the
storybookpackage to our project dependencies.@vonkanehoffen Do you have the
storybookpackage installed as a project dependency?If not, please install it. It’s a peer dep of all the Storybook packages. @dannyhw do we need to add it as a peer dep of
@storybook/react-nativetoo?I have got similar error not when running storybook but when running unit tests. The error message is:
Cannot find module 'storybook/internal/preview-api' from '.yarn/__virtual__/@storybook-react-virtual-*/0/cache/@storybook-react-npm-8.2.0-*.zip/node_modules/@storybook/react/dist'I’ve tried different versions, the error seems related to
@storybook/reactv8.2.0+ where it refers tostorybook/internal/preview-apiinstead ofstorybook/preview-apiin v8.1.