storybook: Storybook running out of memory when building
Describe the bug
After upgrading from 6.0.12 to 6.0.21 when running npx http-server ./lib/storybook -p 8082 -a localhost at 69% built I get: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Note: in the past we have had the same problem on 5.x versions, which were resolved by upgrading node.
I appreciate this lacks a lot of context, and it’s a private repo so I’m unable to share as is, but if anyone is able to point me in the direction of diagnosing or potential causes, that would be of great help.
We are running typescript.
To Reproduce Steps to reproduce the behavior:
Run npx http-server ./lib/storybook -p 8082 -a localhost
Expected behavior Builds as expected
System:
Please paste the results of npx sb@next info here.
System:
OS: Windows 10 10.0.19041
CPU: (8) x64 Intel® Core™ i7-8650U
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs
npm: 6.13.4 - C:\Program Files\nodejs\n
Browsers:
Chrome: 84.0.4147.135
Edge: Spartan (44.19041.423.0), Chromiu
npmPackages:
@storybook/addon-actions: 6.0.21 => 6.0
@storybook/addon-essentials: 6.0.21 =>
@storybook/addon-knobs: 6.0.21 => 6.0.2
@storybook/addon-links: 6.0.21 => 6.0.2
@storybook/addon-toolbars: 6.0.21 => 6.
@storybook/addons: 6.0.21 => 6.0.21
@storybook/react: 6.0.21 => 6.0.21
@storybook/theming: 6.0.21 => 6.0.21
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 27 (5 by maintainers)
This is an issue when using storybook in a monorepo (a repo containing many individual packages and their own node_modules folders). It seems that when using default configs, storybook runs out of memory because it is scanning all of the node_modules sub folders. If I remove all the node_modules folders, it works fine. Is there a recommended way to include storybook in a monorepo? I’m thinking I’ll have to use a custom webpack config that excludes the appropriate folders.
Even with 6GB of RAM in docker, the build still fails:
I just ran into the same error. For me it helped just setting the creation of sourcemap to false in the .storybook/main.js config for vite 2.9.9 with vue 3.2.25 and sb 6.5.9
Since I changed the command from
start-storybook -p 6006 -c .storybooktonode --max_old_space_size=4096 ./node_modules/@storybook/react/bin/index.js -p 6006 -c .storybookit works for me!Writing here to say that I have a large production project that builds storybook in CI. Building was fine using SB v5.3 but 6.3 would not work using Webpack 5 because it would run out of memory. Disabling
reactDocgendid the trick! Thanks Shilman!What happens if you set the following in
.storybook/main.js:I can confirm that this works.
Although in our case the issue was solved by simply not uglifying storybook build.