storybook: Uncaught TypeError: Object(...) is not a function

I have this errors in console, when i run Storybook (tried 5.0.5 and 5.0.3). Does anyone faced with this?

Uncaught TypeError: Object(...) is not a function
    at Function.div (vendors~main.cbfa0565136f7756886e.bundle.js:2795)
    at Object.../../../node_modules/@storybook/components/dist/Badge/Badge.js (vendors~main.cbfa0565136f7756886e.bundle.js:15399)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/components/dist/index.js (vendors~main.cbfa0565136f7756886e.bundle.js:16902)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/dist/components/Panel.js (vendors~main.cbfa0565136f7756886e.bundle.js:10776)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/dist/register.js (vendors~main.cbfa0565136f7756886e.bundle.js:13304)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/register.js (vendors~main.cbfa0565136f7756886e.bundle.js:13372)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 21 (5 by maintainers)

Most upvoted comments

I had this same issue. It was because I was still trying to import action from @storybook/react. It is now imported from @storybook/addon-actions. So I had to update:

import { storiesOf, action } from '@storybook/react';

to

import { storiesOf } from '@storybook/react';
import { actions } from '@storybook/addon-actions';

in all of my .stories.js files

If you’re facing this problem with angular then in my case:

I solved it by importing moduleMetadata from ‘@storybook/angular’ instead of ‘@storybook/angular/dist/client/preview/types’

I also ran into this issue. Turned out it was due to the order of exports in my library – one component was importing a styled-components theme from another module, and accessing it within a styled.div. However, the theme object was exporting after the component in my index.js. Rather than throw an NPE, I saw Uncaught TypeError: Object(...) is not a function.

The weird part for me is it runs fine locally, but throws this error when deployed too Netlify.

@smykes Try to check your repo for circular dependencies. I had the exact same problem as you, where running it locally worked as it should, where building (and deploying it) gave me this error. After removing the circular dependency, it all worked again!

@shilman no, we just abandoned the idea of using the 5.. versions.

@divyeshjethwa thanks! You’re my savior!