question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve 'core-js/modules/es.string.replace' with Storybook 6.0.0-rc.13

See original GitHub issue

Describe the bug I’m using myString.replace(regex) in a custom addon with Storybook 6.0.0-rc.13 and getting the following error during the build process.

Can't resolve 'core-js/modules/es.string.replace' error when building.

This has happened with earlier RCs as well, but did work fine with 6.0.0-rc.0 so I’m guessing it’s related to the version of core-js being used under the covers.

Thanks in advance for any help on resolving this!

To Reproduce Steps to reproduce the behavior:

  1. Create a custom addon with a .jsx file in it
  2. Add a string.replace call into the .jsx file code:
let content = 'my content';
let output = content.replace(/^['"]|['"]$/g, '');
  1. Add the addon into main.js:
module.exports = {
  stories: ['../src/**/*.stories.*'],
  addons: [
    './my-addon/register'
  ]
}
  1. Build and run the project (npm start in my project) and the error appears.

Expected behavior Successful build

Screenshots

2020-07-21_11-00-23

Code snippets Here’s a simplified example of the code causing the error. If I remove the replace() call the build works.

let content = 'some value';
return {
    'data-link': content.replace(/^['"]|['"]$/g, '') // this line causes the build error (if removed the build works)
  },
}

System:

Environment Info:

System: OS: macOS 10.15.5 CPU: (16) x64 Intel® Core™ i9-9900K CPU @ 3.60GHz Binaries: Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node Yarn: 1.22.4 - ~/.nvm/versions/node/v12.18.1/bin/yarn npm: 6.14.6 - ~/.nvm/versions/node/v12.18.1/bin/npm Browsers: Chrome: 84.0.4147.89 Edge: 84.0.522.40 Firefox: 73.0.1 Safari: 13.1.1 npmPackages: @storybook/addon-actions: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-console: ^1.2.1 => 1.2.1 @storybook/addon-docs: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-knobs: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-links: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-storysource: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addons: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/preset-create-react-app: ^3.1.4 => 3.1.4 @storybook/react: 6.0.0-rc.13 => 6.0.0-rc.13

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
zpm683commented, Nov 3, 2020

Step1: And in package.json like this: “@storybook/preset-create-react-app”: “^3.1.4”,

Step2: Add it in .storybook/main.js

module.exports = {
  stories: ["../src/stories/**/*.stories.@(tsx|mdx)"],
  addons: ["@storybook/addon-essentials", "@storybook/preset-create-react-app"],
};

just do it.

4reactions
shraddha-chadhacommented, Sep 23, 2020

I had the same issue with stroybook v6 + React + Typescript and this solved my issue

.storybook/main.js

const path = require('path');

module.exports = {
  stories: ['../src/**/*.stories.@(ts|tsx)'],
  addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-docs'],
  webpackFinal: (config) => {
    config.module.rules.push({
      test: /\.(ts|tsx)$/,
      use: [
        {
          loader: 'babel-loader',
          options: {
            presets: ['babel-preset-react-app']
          }
        }
      ],
      include: path.resolve(__dirname, '../src'),
      exclude: /node_modules/,
    });
    return config;
  },
};

And .storybook/.babelrc { "presets": [ "babel-preset-react-app" ] }

And package.json "babel-preset-react-app": "^9.1.2",

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'core-js/es6'
To resolve this error, you can downgrade the core-js version to 2.5.7. This version produces correct catalogs structure, with separate ES6 ...
Read more >
Module not found: Error: Can't resolve 'core-js/client/shim'
solution install core-js@2.6.5. ... Module not found: Error: Can't resolve 'core-js/modules/es6.object.create ... import 'core-js/es/reflect';.
Read more >
mmb.irbbarcelona.org/gitlab/aluciani/MoDEL-CNS_cli...
**Note:** This file only supports Node's JavaScript syntax. Be sure to only use supported language features (i.e. no support for Flow, ES Modules,...
Read more >
Gatsby Changelog | 5.3.0
v5.3 Release Notes | December 13 2022. ... ES Modules (ESM) in Gatsby files; Improved error messages ... gatsby-core-utils :.
Read more >
@storybook/react-native-server | Yarn - Package Manager
With Storybook for React Native you can design and develop individual React Native components without running your app. For more information visit: storybook.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found