storybook: Cannot find module 'react/package.json'
Describe the bug npm run storybook Cannot find module ‘react/package.json’
To Reproduce Steps to reproduce the behavior:
npm init
npx -p @storybook/cli sb init --type react
npm run storybook
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 15 (3 by maintainers)
Also need to have react-dom installed as a dev dependency.
In my case, I needed both
reactandreact-domas devDependencies.i.e.
npm install --save-dev react react-domCheck if you have added react as part of peer dependencies. It has to be there in dependencies also.
@gaetanmaisse FYI we’re recommending this, which is functionally equivalent to your recommendation, but shorter/simpler:
npx -p @storybook/cli sb initHi guys just checked again if anyone facing the error make sure to run :
npm uninstall storybookagain installnpm install storybook@xiangxiong running
npx -p @storybook/cli sb init --type reactlet you init Storybook in an already bootstrapped React app, which isn’t your case as you’re only doingnpm init.If you want to bootstrap a React app + Storybook you can do the following:
I let you close this issue if my answer solves your problem, otherwise, I let you provide a repro repo.
In my case, with a simple storybook setup, reinstalling node_modules with
npm installafter deleting the previous node_modules and package-lock.json solved the issue.