Storybook: TypeError: Object.values is not a function

Created on 9 Jul 2018  Â·  4Comments  Â·  Source: storybookjs/storybook

Bug or support request summary

After upgrading to webpack4 I can't run storybook because of error "TypeError: Object.values is not a function".

Logs:

ERROR in ./.storybook/addons.js
Module build failed (from ./node_modules/@storybook/react/node_modules/babel-loader/lib/index.js):
TypeError: Object.values is not a function
    at Object.<anonymous> ([project-path]\node_modules\babel-plugin-react-docgen\lib\index.js:47:30)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at [project-path]\node_modules\babel-core\lib\transformation\file\options\option-manager.js:178:20
    at Array.map (native)
 @ multi ./.storybook/addons.js ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/core/dist/client/manager/index.js +0

ERROR in ./.storybook/config.js
Module build failed (from ./node_modules/@storybook/react/node_modules/babel-loader/lib/index.js):
TypeError: Object.values is not a function
    at Object.<anonymous> ([project-path]\node_modules\babel-plugin-react-docgen\lib\index.js:47:30)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at [project-path]\node_modules\babel-core\lib\transformation\file\options\option-manager.js:178:20
    at Array.map (native)
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js +3

Steps to reproduce

Content of .storybook/addons.js:

import '@storybook/addon-actions/register';
import '@storybook/addon-knobs/register';

Content of .storybook/config.js:

require('babel-plugin-require-context-hook/register')();
import {configure} from '@storybook/react';

const req = require.context('../src', true, /\.stories\.jsx?$/);

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

configure(loadStories, module);

Content of .babelrc:

{
  "presets": [
    "env",
    "stage-0",
    "react",
    "flow"
  ],
  "plugins": [
    ["transform-runtime", "transform-decorators-legacy", "transform-class-properties", "transform-react-jsx-source", "require-context-hook"]
  ],
  "compact": true
}

There is no custom webpack.config

Please specify which version of Storybook and optionally any affected addons that you're running

  • "@storybook/addons": "^4.0.0-alpa.3",
  • "@storybook/addon-actions": "4.0.0-alpha.3",
  • "@storybook/addon-knobs": "4.0.0-alpha.3",
  • "@storybook/react": "4.0.0-alpha.3",

Affected platforms

  • "webpack": "^4.12.0",
  • "webpack-cli": "^3.0.6",
  • "babel-cli": "^6.26.0 "
  • "babel-core": "^6.26.0",
  • "babel-loader": "^7.1.2"

  • node: v6.11.1

  • npm: 5.4.2
inactive

Most helpful comment

Upgrading node from v6 to v8 resolved this problem for me.

All 4 comments

I'm experiencing the same!

→ node -v
v6.14.3

→ npm -v
3.10.10

@kastrulya
As an work-around here, I've added in the first line of my .storybook/config.js the line:

Object.values = (obj) => Object.keys(obj).map(key => obj[key]);

Hope it helps!

Upgrading node from v6 to v8 resolved this problem for me.

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 30 days. Thanks!

Was this page helpful?
0 / 5 - 0 ratings