lifeiscontent / storybook-addon-next-router

Addon to use Next.js Router in Storybook
MIT License
107 stars 23 forks source link

Can't access @storybook/addon-actions inner @storybook/addon-essential #42

Closed hwookim closed 2 years ago

hwookim commented 2 years ago

I have an error while building storybook. There's @storybook/addon-actions under @storybook/addon-essentials. But storybook-addon-next-router can't access that package.

Should I install @storybook/addon-actions even if @storybook/addon-essentials installed?

ERROR in ./.yarn/__virtual__/storybook-addon-next-router-virtual-8fe569dae7/0/cache/storybook-addon-next-router-npm-3.0.8-19bfb172f2-895f11e551.zip/node_modules/storybook-addon-next-router/dist/decorators.js
Module not found: Error: storybook-addon-next-router tried to access @storybook/addon-actions (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

Required package: @storybook/addon-actions
Required by: storybook-addon-next-router@virtual:ae15530bbbc46884441dae3a3b557d88a86d41844b08a4831ae3d2468314271227fc9a06f07d0d4f595dbacd3ed95f394743808ceffba188dcf45c82ebb415d1#npm:3.0.8 (via /Users/hwookim/Documents/TILBox/client/.yarn/__virtual__/storybook-addon-next-router-virtual-8fe569dae7/0/cache/storybook-addon-next-router-npm-3.0.8-19bfb172f2-895f11e551.zip/node_modules/storybook-addon-next-router/dist/decorators.js)
Ancestor breaking the chain: tilbox@workspace:.
...
//yarn.lock
...
"@storybook/addon-essentials@npm:^6.3.12":
  version: 6.3.12
  resolution: "@storybook/addon-essentials@npm:6.3.12"
  dependencies:
    "@storybook/addon-actions": 6.3.12
...

Could it be yarn-beery problem? It's running with yarn-berry.

lifeiscontent commented 2 years ago

@shilman any thoughts here?

shilman commented 2 years ago

yes, you need to add a direct dependency on @storybook/addon-actions if you want to access it directly in your code OR if another package like this one has it as a peer dependency. i believe this has always been the case, but only recently package managers have gotten more strict about enforcing it. if you want to be safe, add it to the addon's installation instructions

hwookim commented 2 years ago

@shilman thx!

Come to think of it, it would be better to specify the necessary packages. I should be careful from now on. 😄