storybook: storybook/react is missing renderToDOM function
Describe the bug Cannot start sb dev without error in alpha.35 version. UI is blocked by missin renderToDOM field.
To Reproduce run
npm run storybook caused error
ERR! Error: Cannot find module ‘@storybook\react\preset’ ERR! Require stack: ERR! - C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js ERR! - C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\dist\cjs\index.js ERR! - C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\cli\dist\generate.js ERR! - C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\cli\bin\index.js ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15) ERR! at Function.Module._load (node:internal/modules/cjs/loader:804:27) ERR! at Module.require (node:internal/modules/cjs/loader:1028:19) ERR! at require (node:internal/modules/cjs/helpers:102:18) ERR! at $ (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:6:16) ERR! at fr (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:20:118) ERR! at ye (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:20:207) ERR! at C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:22:323 ERR! at Array.map (<anonymous>) ERR! at A (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:22:310) ERR! at be (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:22:821) ERR! at pr (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\node_modules@storybook\core-common\dist\index.js:22:1117) ERR! at buildDevStandalone (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\core-server\dist\cjs\build-dev.js:117:50) ERR! at async un (C:\Users\marcel.kocisek\Documents\sppd-webapp\node_modules@storybook\cli\dist\generate.js:258:1900) ERR! Error: Cannot find module ‘@storybook\react\preset’
UI error
Expected your framework’s preset to export a renderToDOM field.
Perhaps it needs to be upgraded for Storybook 6.4?
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field
storybook=
System System: OS: Windows 10 10.0.19044 CPU: (4) x64 Intel® Core™ i5-7300HQ CPU @ 2.50GHz Binaries: Node: 16.17.0 - ~\AppData\Local\nvs\default\node.EXE Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 8.15.0 - ~\AppData\Local\nvs\default\npm.CMD Browsers: Chrome: 106.0.5249.91 Edge: Spartan (44.19041.1266.0), Chromium (106.0.1370.34), ChromiumDev (107.0.1402.2) npmPackages: @storybook/addon-actions: 7.0.0-alpha.35 => 7.0.0-alpha.35 @storybook/addon-essentials: 7.0.0-alpha.35 => 7.0.0-alpha.35 @storybook/builder-vite: 0.2.3 => 0.2.3 @storybook/cli: ^7.0.0-alpha.35 => 7.0.0-alpha.35 @storybook/react: 7.0.0-alpha.35 => 7.0.0-alpha.35
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (8 by maintainers)
@IanVS thank you for you reply.
Maybe this will help someone else :
I had to try
npx storybook@next init -p tsx -b vite --package-manager yarn1 --type reactwith the turbo repo basic example to see if that works.Under package I created a new storybook folder just next to the ui folder I installed vite, added the ui workspace to package.json
– apps — web — docs – packages — ui — storybook
For some reason storybook fails to resolve entry for package “ui”
13:44:42 [vite] Internal server error: Failed to resolve entry for package "ui". The package may have incorrect main/module/exports specified in its package.json.So I had to add an alias to viteFinal in main.js
Edit 1: However, for some reason, I still have the same error even with the rc release in my initial project
Failed to load preset: "@storybook\\react-vite\\preset"Edit 2: Solved the first issue by installing
@storybook/react-vitein the monorepo root.Now I have a different issue
Environment Info:
@mandarini this is because your
vite.config.tsis not in the same folder as you’re running the command from (not in CWD). A new option was recently added to handle this case, so in the most recent betas, you can update yourmain.jslike this:When I try this in your repo, after updating to beta.34, it builds fine after removing viteFinal.
@IanVS this was helpfull. Storybook is running.
@MarcelGeo if you’re using 7.0, there are some changes that are needed to your config file. See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field for details, but basically you need to change the
frameworkto@storybook/react-vite(and install it if it’s not already installed in your project, with the same version as the other packages). Also note, that you don’t need to useviteFinalanymore, if all you’re doing is duplicating config from yourvite.config.jsfile, since storybook will read that config automatically now in 7.0.@MarcelGeo can you share your
main.cjs?@hanscl Glad you got it working. FWIW, you no longer need to specify
core.builderin 7.0 config. That’s handled by theframeworknow.Ah, you’ll need to update builder-vite to 7.0, the same alpha as the rest.