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.

Storybook stops working on Create-react-app (CRA) after ejecting

See original GitHub issue

Describe the bug Storybook stops working, after ejecting CRA. Gives Module parse failed: Unexpected token error.

To Reproduce Steps to reproduce the behavior:

  1. Install CRA npx create-react-app storybook-typescript-eject --typescript and cd storybook-typescript-eject.
  2. Install Storybook npx -p @storybook/cli sb init
  3. Verity it works npm run storybook
  4. Eject npm run eject press y to confirm.
  5. Change Storybook config. Replace loadStories with:
function loadStories() {
  // automatically import all story js files that end with *.stories.tsx
  const req = require.context("../src", true, /\.stories\.tsx$/);
  req.keys().forEach(filename => req(filename));
}
  1. Rename story file to stories/index.stories.tsx
  2. Verify that it doesn’t recognize JSX-tag. npm run storybook

Expected behavior I expected the same config that worked before ejecting would work after.

System:

  • OS: MacOS Mojave and Windows 7
  • Framework: React
  • Version: Latest

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Dergashcommented, Feb 10, 2020

Hello! I’ve encountered the similiar issue and based on @mrmckeb response about separate configuration drafted a configuration that gave me the same behaviour which I had before ejecting CRA: https://github.com/storybookjs/presets/issues/72#issuecomment-584284246 Hope it’ll help someone who is in the same situation

0reactions
mrmckebcommented, Jul 22, 2019

Let me know if you need a hand with that, in the meantime I’ll close this off as it’s expected behaviour.

Also, consider forking react-scripts over ejection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack error adding storybook to create-react-app
I have the exact same issue with latest CRA/storybook, CRA not ejected thus webpack config hidden in node_modules and not customised. It seems ......
Read more >
Stop Ejecting Create React App - YouTube
Instead of ejecting CRA ( Create # React App ) you can get access to many option by using Craco. In this lesson...
Read more >
Create React App: import modules using aliases ... - Wavelop
You can take a look at a demo here. Initialize project using Create React App. Execute the following commands: npx create-react-app cra-with-module-alias ...
Read more >
Frequently Asked Questions - Storybook - JS.ORG
If you have a question, you can ask it by opening an issue on the Storybook Repository ... Create React App does not...
Read more >
Migrating a Create-React-App project into an Nx Workspace
The command above will detect that the project is generated with CRA, and that it has not been ejected, or _ customized_ with...
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