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.

Gatsby + TS + Storybook gives 'babel-preset-react-app' error

See original GitHub issue

Storybook does not run when I try to use it inside Gatsby with TypeScript.

To Reproduce Steps to reproduce the behavior:

  1. Use https://github.com/gojutin/gatsby-starter-typescript-deluxe
  2. Modify webpack.config.js:
// this is so we're able to run .tsx files
config.module.rules.push({
    test: /\.(ts|tsx)$/,
    loader: require.resolve("babel-loader"),
    exclude: /node_modules/,
    options: {
      presets: [["react-app", { flow: false, typescript: true }]],
      plugins: ["babel-plugin-styled-components"],
    },
  }
  1. Run yarn build and then yarn storybook (otherwise there is an babel error)
  2. See error:
// console
WARNING in ./src/stories/index.stories.tsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'babel-preset-react-app'
// browser error
Uncaught TypeError: (0 , _typeof3.default) is not a function

System: Stroybook: 5.2.5 gatsby: 2.17.9 gatsby-plugin-typescript: 2.1.15

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
albshincommented, Jan 23, 2020

Upgraded from 5.2.6 to 5.3.8 and got the same error. Installing babel-preset-react-app solved this issue.

2reactions
PaulieScanloncommented, Jun 24, 2020

@themre I wrote a couple of recipes to help in setting up Storybook + Gatsby and TypeScript / JavaScript. They are both available through the official Gatsby CLI, more info here: https://paulie.dev/posts/2020/05/gatsby-cli-recipes/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Start a component library with Storybook, Tailwind, and ...
Build components faster for your React project. Take a look at the final result. What is Storybook? Storybook is a tool for developing...
Read more >
how to solve this error You may need an appropriate loader to ...
I am using react-navigation along with react-native-web (typescript). When I am trying to include react-navigation module, it is giving error.
Read more >
@storybook/react-native-server | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Creating a React Component Library using Rollup, Typescript ...
Storybook provides a sand-boxed environment for your front-end projects that ... src/index.ts will be used as the entry point for Rollup.
Read more >
Setting up Storybook for Gatsby - Imran Sayed
Storybook is a user interface development environment and playground for UI components. The tool enables developers to create components independently and ...
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