Unable to resolve module @storybook/core/manager-api
Opened this issue · 12 comments
When running the starter project (tested for both android and iOS, and after running all install commands), I receive this error:
Unable to resolve module @storybook/core/manager-api from /node_modules/@storybook/addon-ondevice-controls/dist/index.js: @storybook/core/manager-api could not be found within the project...
It seems this is out-of-the-box, and the starter project will not run. Am I missing something obvious?
let me check, I have recently pushed some fixes that I need to update the examples to reflect
Sorry for the delay, I'm maintaining a lot of example projects so it takes a while 😅
that error is from not having package exports enabled in metro, though it should run if you use yarn storybook:ios
or just edit withStorybook in metro to enabled:true
OK nvm I broke it in my recent release but I have a fix coming in the next 10 mins
@trooperandz should be fixed in 8.3.9 and by keeping the withStorybook config enabled. Theres probably still some tweaking to do here on my part, metro is just really tricky 😅
some code I've added to this example to make everything work as expected and remove storybook from non storybook builds.
( see the metro config file )
const config = {
resolver: {
resolveRequest: (context, moduleName, platform) => {
if (
(moduleName.startsWith('storybook') ||
moduleName.startsWith('@storybook')) &&
process.env.STORYBOOK_ENABLED !== 'true'
) {
return {
type: 'empty',
};
}
return context.resolveRequest(context, moduleName, platform);
},
},
};
Experimenting with adding this to withStorybook
as an option.
https://github.com/storybookjs/react-native/pull/622/files
probably will ship it as it seems harmless as an option
@dannyhw thanks for looking at this.
I pulled down the project again (fresh start) after the updates, and had a few issues:
-
Had to set my own
STORYBOOK_ENABLED
env var to get the app to run (maybe the example project should just have an a.env
file with this value in it since it has to be changed to work out of the box and is a little bit of a surprise that it doesn't run)? -
After resolving the above, then I ran into the
transformer.unstable_allowRequireContext
metro configuration error (I realize there is a note having to set this this totrue
in the main docs, but maybe the starter project should have this in it since it should run out of the box and I couldn't get metro to run without changing it, which was a surprise). -
Finally, I got this error after the two above were resolved:
TypeError: 0, _$$_REQUIRE(_dependencyMap[8](...)"@storybook/react-native").start is not a function (it is undefined)
, thrown from thestorybook.requires.ts
file.
Let me know if I missed some steps or anything; I just pulled it down, installed the dependencies, and ran a pod install for iOS before building it in Xcode. Thanks!
The storybook enabled var is set in the script you run from package.json, are you saying the storybook script wasn't working for that?
If you are going to run from xcode yeah it won't work since the env is not set. Though it will work if you use yarn storybook
to start metro with storybook enabled first
Thanks @dannyhw . Yes, running with the package.json command fixes this. However, there are still the other two issues I encountered mentioned above, resulting in the following errors:
I've not run into this issue myself when i run the project but i will take a look soon and see if i can reproduce.
You'll only get that if the env variable is turned off an you try to run storybook
Thanks. I guess I ran that incorrectly; it's working now, thanks!
@trooperandz glad its working! Thanks for your patience on this, I know its not been easy to get setup. Hopefully I can make it easier. If you have any suggestions for improving documentation or anything else that could be make it easier to get setup i'd be happy to hear it 🙏