Storybook: Error using storyshots

Created on 15 Apr 2017  路  5Comments  路  Source: storybookjs/storybook

Issue by fdaciuk
_Thursday Apr 13, 2017 at 23:11 GMT_
_Originally opened as https://github.com/storybooks/storybook-addon-options/issues/17_


I'm using storybook-readme and storyshots on my project. When I try to run storyshots -c storybook on terminal, I get this error:

TypeError: Cannot read property 'emit' of null
    at setOptions (/code/my-project/node_modules/@kadira/storybook-addon-options/dist/preview/index.js:27:10)
    at evalmachine.<anonymous>:20:39
    at runWithRequireContext (/code/my-project/node_modules/@kadira/storyshots/dist/require_context.js:104:3)
    at _callee$ (/code/my-project/node_modules/@kadira/storyshots/dist/cli.js:29:43)
    at tryCatch (/code/my-project/node_modules/regenerator-runtime/runtime.js:64:40)
    at Generator.invoke [as _invoke] (/code/my-project/node_modules/regenerator-runtime/runtime.js:299:22)
    at Generator.prototype.(anonymous function) [as next] (/code/my-project/node_modules/regenerator-runtime/runtime.js:116:21)
    at step (/code/my-project/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /code/my-project/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at F (/code/my-project/node_modules/core-js/library/modules/_export.js:35:28)
error Command failed with exit code 1.
error Command failed with exit code 1.

My storybook config files (click to open):


config.js

import { configure, addDecorator, setAddon } from '@kadira/storybook'
import GithubCorner from '@personare/react-storybook-decorator-github-corner'
import InfoAddon from '@kadira/react-storybook-addon-info'
import { setOptions } from '@kadira/storybook-addon-options'

addDecorator(GithubCorner)
setAddon(InfoAddon)

setOptions({ downPanelInRight: true })

const req = require.context('../src/components', true, /\.story\.js$/)

function loadStories () {
  req.keys().forEach((filename) => req(filename))
}

configure(loadStories, module)


addons.js

import '@kadira/storybook/addons'
import '@kadira/storybook-addon-options/register'
import 'storybook-readme/register'


Any ideas?

cc @mnmtanish @arunoda

options bug inactive

Most helpful comment

I'm running into the same issue for all addons. From what I can tell, it looks like none of the addons addons.register are being called. For example the action addon.

...Going in further to the dist and src folder inside of the node_modules... I see that the singleton behavior of AddonStore is not being respected.

What happens is that when addons.js runs the addons are added to one instance of the store. and then during the react render another instance is being populated.

During addons.js -> node_modules\@storybook\addons\dist\index.js
During ReactProvider -> node_modules\@storybook\addons\src\index.js

To reproduce

// in addons.js
import addonStore from  "@storybook/addons"
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';

console.log(addonStore) // addons properly registered

Then add in the comment to ReactProvider

 handleAPI(api) {
   // ...
  console.log(addons) //; will not contain the addons
  }

The quick fix is to go into your node_modules folder node_modules\@storybook\react and delete the nested node_modules\@storybook\addons which cause the duplication.

Basically storybook/react wants to pull in its own node_modules but you cant just remove the storybook/addons because then each addon will be missing its dependency

ERROR in ./~/@storybook/addon-links/dist/manager.js
Module not found: Error: Can't resolve '@storybook/addons' in '...app\node_modules\@storybook\addon-links\dist'

All 5 comments

Got the same error.
For me the issue was the upgrade from babel-loader 6.4.1 to babel-loader 7.0.0.

After reverting to 6.4.1, every used addon works fine again.

@ChrisHaPunkt I'm using [email protected]. I've tried to install [email protected] and 7.0.0, but no success :disappointed: :thinking:

I'm running into the same issue for all addons. From what I can tell, it looks like none of the addons addons.register are being called. For example the action addon.

...Going in further to the dist and src folder inside of the node_modules... I see that the singleton behavior of AddonStore is not being respected.

What happens is that when addons.js runs the addons are added to one instance of the store. and then during the react render another instance is being populated.

During addons.js -> node_modules\@storybook\addons\dist\index.js
During ReactProvider -> node_modules\@storybook\addons\src\index.js

To reproduce

// in addons.js
import addonStore from  "@storybook/addons"
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';

console.log(addonStore) // addons properly registered

Then add in the comment to ReactProvider

 handleAPI(api) {
   // ...
  console.log(addons) //; will not contain the addons
  }

The quick fix is to go into your node_modules folder node_modules\@storybook\react and delete the nested node_modules\@storybook\addons which cause the duplication.

Basically storybook/react wants to pull in its own node_modules but you cant just remove the storybook/addons because then each addon will be missing its dependency

ERROR in ./~/@storybook/addon-links/dist/manager.js
Module not found: Error: Can't resolve '@storybook/addons' in '...app\node_modules\@storybook\addon-links\dist'

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 60 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings