storybook: React: `_jsx is not defined` error
_Originally posted by @nandosangenetto in https://github.com/storybookjs/storybook/issues/12881#issuecomment-718969472_
I’m getting the same error that @DiFuks is getting, _jsx is not defined.

I’ve created a small repo where you can reproduce this bug: https://github.com/nandosangenetto/storybook-bug-repro
I’ve tried to remove all addons, as @DiFuks did, but it didn’t work.
What is odd is that it works when I run npm run storybook (start-storybook -p 6006), but fails when I try to build it with npm run build-storybook (build-storybook).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 33 (12 by maintainers)
Commits related to this issue
- fix sb issue React: `_jsx is not defined` error #12952 https://github.com/storybookjs/storybook/issues/12952#issuecomment-733088956 — committed to lowsky/gh-dashboard-relay by lowsky 4 years ago
- fix sb issue React: `_jsx is not defined` error #12952 https://github.com/storybookjs/storybook/issues/12952#issuecomment-733088956 — committed to lowsky/gh-dashboard-relay by lowsky 4 years ago
- Update dependencies Add local .babelrc for React Storybook https://github.com/storybookjs/storybook/issues/12952#issuecomment-740648850 — committed to tyom/storybook-addons by tyom 3 years ago
Same solution for me, but with a less duplicated configuration:
@sibelius Unfortunately, the problem has not been resolved.
I resorted to patching the babel config like so (in
main.js):I’m experiencing this with
v6.1.6and I found this issue while sorting through an issue of my own.I used @DiFuks’s example, and also needed a workaround from Chakra’s own repo. I was able to remove the duplicate
.babelrcfrom the.storybookdirectory, and I no longer need to use--no-dll.Below is my
main.jsfile, and this is the minimum I found required for me to get storybook working without the_jsxissue.Adding this minimal
/.storybook/.babelrcworked for me (using next.js):I have the same issue.
The solution for me - just to copy the
.babelrcfile into.storybookfolder. E.g.:cp .babelrc .storybook/BTW, I have tried to upgrade a storybook version via
npx sb upgrade, but, actually, helpless.@shilman @DiFuks I had the same issue (
_jsx is not defined).Copying
<root>/.babelrcto<root>/.storybook/.babelrcdid help. I usenext, btw.Storybook version is
@storybook/react v6.1.0-alpha.35Next version is10.0.1React version is17.x============ Btw, I don’t use
--no-dllflag, but it’s still yelling about(node:8752) DeprecationWarning: DLL-related CLI flags are deprecated, see: %url%. What’s wrong with this deprecaation?@Fi1osof I’m seeing a slightly different error which is
_jsxs is not defined. Can you confirm? Also which version ofnpmare you using?@shilman here: https://github.com/prisma-cms/component-boilerplate/tree/76d2516757491068c3cfc1df5dc143ef69437b73 For repro error please remove .storybook/.babelrc
@nandosangenetto i think this is unrelated to #12881, or only tangentially related. i copied
.babelrcinto the.storybookdirectory and the error went away. LMK if that works for you.i did, however, see something very troubling, which is:
main.jsconfig to remove the addons (which you also tried)storybook-staticand the addons were still being installednode_modules/.cacheand rebuildingstorybook-staticin the end deleting
node_modules, reinstalling, and rebuilding worked. i’ve never seen this before, and i didn’t have time to follow up. is there anything special about your project that might cause this?