storybook: utility.assert is not a function

Describe the bug Storybook fails to build throwing the following errors:

TypeError: utility.assert is not a function

Error loading story index:

Error: Cannot parse JSDoc tags.

System

System: OS: macOS 12.0.1 CPU: (8) x64 Apple M1 Binaries: Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm Browsers: Firefox: 96.0.3 Safari: 15.1 npmPackages: @storybook/addon-actions: 6.4.18 => 6.4.18 @storybook/addon-docs: 6.4.18 => 6.4.18 @storybook/addon-essentials: 6.4.18 => 6.4.18 @storybook/addon-links: 6.4.18 => 6.4.18 @storybook/addons: ^6.4.18 => 6.4.18 @storybook/builder-webpack5: 6.4.18 => 6.4.18 @storybook/manager-webpack5: 6.4.18 => 6.4.18 @storybook/react: 6.4.18 => 6.4.18 @storybook/testing-react: ^1.2.3 => 1.2.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 38 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I ended up disabling the @storybook/addon-docs to get rid of the error. This can be done by replacing the '@storybook/addon-essentials' in the main config with the following:

   ...
    {
      name: '@storybook/addon-essentials',
      options: {
        docs: false,
      },
    },

This isn’t a fix or workaround. It’s just a way to get rid of the error by disabling the add-on as described in docs.

alternatively, you can add a fallback to the webpackFinal config function and provide a polyfill.

In this case, you can add the commonjs-assert package.

yarn add --dev commonjs-assert

Then add a property to the webpack final config in main.js

const path = require('path');
const toPath = (filePath) => path.join(process.cwd(), filePath);
...
module.exports = {
 webpackFinal: async (config) => ({
    ...config,
    resolve: {
      ...config.resolve,
     // can likely be removed in storybook > 6.4 see - https://github.com/storybookjs/storybook/issues/17458
     fallback: {
       ...config.resolve.fallback,
      'assert': toPath('commonjs-assert')
     }
    },
 })
}

In any case going to close this as it is fixed in 7.0. Please try upgrading if you are still seeing problems!