无法安装storybook

来源:8-2 安装 Storybook

Amormo

2022-10-19

这里是仓库地址
先后尝试过 node 14.19.0 和 16.15.0
先后尝试过pnpxnpx

主要错误信息:

$ npx storybook init

 storybook init - the simplest way to add a Storybook to your project. 

 • Detecting project type. ✓
 • Adding Storybook support to your "Create React App" based project
attention => Storybook now collects completely anonymous telemetry regarding usage.
This information is used to shape Storybook's roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://storybook.js.org/telemetry

npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\An\AppData\Local\npm-cache\_logs\2022-10-18T14_00_26_611Z-debug-0.log
An error occurred while installing dependencies.

老师可以帮忙看看吗?

写回答

2回答

张轩

2022-10-21

同学你好

我使用你的的 repo 成功安装运行完毕,请看截图:

https://img.mukewang.com/szimg/6351fa7b094b78ba15360644.jpg

说一下具体流程:

MacOS 系统 Intel 内核
1 clone
2 node 版本 16.13.0
3 npm install
4 npx storybook init
// 中间会有一个提示:found a 'npm7' migration:
Do you want to run the 'npm7' migration on your project? … 
// 这里 y 然后回车
5 npm run storybook

建议同学将 node_modules 删除,按照这个顺序完全跑一遍呢。

0
2
Amormo
谢谢老师 解决了
2022-10-22
共2条回复

张轩

2022-10-19

同学你好 看起来这是 storybook 最近的一个 issue: https://github.com/storybookjs/storybook/issues/18111

和 NPM 有关,帖子中有一个具体的解决方案,可以试一下,地址

https://github.com/storybookjs/storybook/issues/18111#issuecomment-1139589898

内容:

# Remove workspace dependencies. ()
rm -rf ./node_modules
rm -rf ./pnpm-lock.yaml

# Remove packages dependencies.
pnpm -r exec rm -rf ./node_modules

rm -rf $(pnpm store path)

pnpm dlx sb@latest upgrade 

# Convert package-lock.json to pnpm-lock.json
pnpm import


0
1
Amormo
老师 我也搜到了这个issue 但是在本地尝试没有成功 可以再帮忙看看吗
2022-10-20
共1条回复

React18+TS高仿AntD从零到一打造组件库

设计,开发,测试,发布再到 CI/CD,从0到1造轮子

2123 学习 · 959 问题

查看课程