Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Addon Error "Cannot read property 'emit' of null" #1

Closed
thani-sh opened this issue Aug 12, 2016 · 8 comments
Closed

Addon Error "Cannot read property 'emit' of null" #1

thani-sh opened this issue Aug 12, 2016 · 8 comments

Comments

@thani-sh
Copy link
Contributor

Related issue: mthuret/storybook-addon-specifications#1

This issue is somewhat weird:

@tomitrescak got the error message

Cannot read property 'emit' of null

Which means that the addons variable here must be already available and addons.getChannel() call was successful. Which means @kadira/storybook-addons was already available.

The weird thing is that it started working once he installed @kadira/storybook-addons. Maybe it was some node module version mixups or its something else.

I checked the mthuret/storybook-addon-specifications code and the way it's using addons.getChannel() is fine. I tried setting up this addon with the react-button repo and it also worked fine.

cc: @arunoda @roonyh

@arunoda
Copy link
Contributor

arunoda commented Aug 12, 2016

We need to check with @tomitrescak he is using NPM2?

@arunoda
Copy link
Contributor

arunoda commented Aug 12, 2016

We need to do some webpack hack and try to load the same @kadira/storybook-addons in all the cases. (Using webpack's alias)

Then we may use @kadira/storybook-addons as a peer dependancy.
Not sure this'll fix that issue, then we know everyone on the same page.

@thani-sh
Copy link
Contributor Author

All addons have @kadira/storybook-addons as a peer dependency and @kadira/storybook has it as a dependency. So it should work fine, right?

@arunoda
Copy link
Contributor

arunoda commented Aug 12, 2016

@mnmtanish Ah yes. In that case, it should work properly.
May be the version of @kadira/storybook-addons in the @kadira/storybook is a older one.
Which don't have that emit method.

So, when the user installed @kadira/storybook-addons manually it will show up properly.

@thani-sh
Copy link
Contributor Author

The emit method comes from the channel. From the error we can see that the user got null instead of the channel. This can happen when multiple versions of @kadira/storybook-addons gets loaded somehow. I think the one on react-storybook gets the addons.setChannel call and the one (somehow) loaded by the addon gets the addons.getChannel call.

Is there any node feature to make sure only one version of a module gets loaded?
Is it okay to use a global variable to check whether multiple versions are loaded?

@tomitrescak
Copy link

Guys, the error was that I was using older version of storybook ... shame on me :/

@arunoda
Copy link
Contributor

arunoda commented Aug 12, 2016

Thanks @tomitrescak.
The think I guess might be correct.
I think we can close this now.

@arunoda arunoda closed this as completed Aug 12, 2016
@darthtrevino
Copy link

FYI, if you run into this while developing addons, I had to update .storybook/webpack.config.js:

const path = require('path');
module.exports = {
  ...<your wepback conf>...
  resolve: {
    alias: {
      '@kadira/storybook-addons': path.join(__dirname, '../node_modules/@kadira/storybook-addons'),
    },
  },
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants