Angular - Error: Cannot find module 'react/package.json' when build preview #17835
-
Hey all. Project stack:
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 17 replies
-
Seems like storybook has something wrong with its dependencies.
but it should be the storybook dependency/package who has to install these dependencies and it should not be explictly part of your own package.json |
Beta Was this translation helpful? Give feedback.
-
I have the exact same issue but with Angular 13, NX Workspace 13, Storybook 6.4.12 |
Beta Was this translation helpful? Give feedback.
-
Thank you, will try. |
Beta Was this translation helpful? Give feedback.
-
Also having this problem. Any luck? |
Beta Was this translation helpful? Give feedback.
-
For those who still have this issue I manage to solve that. By investigating each file that storybook works with, I realized that my tsconfig.json that storybook was aimed to and main.js had incorrect setup. They pointed to incorrect paths. After setting the correct paths everything started to work. |
Beta Was this translation helpful? Give feedback.
-
This is still happening in 2023 after installing a new Angular project, installing Storybook, and using |
Beta Was this translation helpful? Give feedback.
@milenig, @EvanScott542 Please help me to understand the issue. As @shilman pointed out,
react
andreact-dom
are necessary peer-dependencies for Storybook. So either your package manager automatically installs them for you, or you must install them manually. We plan to remove these peer-dependencies in Storybook 8.When Storybook is initiated freshly in a project, Storybook's CLI will automatically install these. Upgrading Storybook from 6 to 7 via
npx storybook@latest upgrade
should also take care of installingreact
andreact-dom
as a peer dependency. If this doesn't happen, you have to add these dependencies manually.Is there still something unclear? Does the error occur, although
react
…