Gatsby + TS + Storybook gives 'babel-preset-react-app' error
See original GitHub issueStorybook does not run when I try to use it inside Gatsby with TypeScript.
To Reproduce Steps to reproduce the behavior:
- Use https://github.com/gojutin/gatsby-starter-typescript-deluxe
- 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"],
},
}
- Run
yarn build
and thenyarn storybook
(otherwise there is an babel error) - 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:
- Created 4 years ago
- Reactions:5
- Comments:16 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Upgraded from
5.2.6
to5.3.8
and got the same error. Installingbabel-preset-react-app
solved this issue.@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/