Storybook错误:在“@storybook/react”包中缺少“./preview.js”指定符

huangapple go评论76阅读模式
英文:

Storybook error: Missing "./preview.js" specifier in "@storybook/react" package

问题

I am trying to integrate together storybook, react, vite and TS.

当尝试运行storybook时,在控制台中出现以下错误:

在“@storybook/react”包中缺少“./preview.js”规范符号
4:02:06 PM [vite] 内部服务器错误:在“@storybook/react”包中缺少“./preview.js”规范符号
  插件:vite:import-analysis

我的故事都被很好地发现和列出,但预览显示一个无限的圆形加载器。

我尝试用vite创建一个新的React/TS Web应用程序。

yarn create vite my-app --template react-ts

然后我通过简单地运行以下命令集成storybook:

npx sb init --builder @storybook/builder-vite

我有以下开发依赖项:

    "@storybook/addon-essentials": "^7.0.17",
    "@storybook/addon-interactions": "^7.0.17",
    "@storybook/addon-links": "^7.0.17",
    "@storybook/blocks": "^7.0.17",
    "@storybook/builder-vite": "^7.0.17",
    "@storybook/react": "^7.0.17",
    "@storybook/react-vite": "^7.0.17",
    "@storybook/testing-library": "^0.0.14-next.2",

    "storybook": "^7.0.17",
    "typescript": "^5.0.2",
    "vite": "^4.3.9"

我没有在任何地方找到解决方案。这里有人遇到了相同的问题吗?

非常感谢您的帮助。

英文:

I am trying to integrate together storybook, react, vite and TS.

When trying to run storybook, I have the following error in the console:

Missing "./preview.js" specifier in "@storybook/react" package
4:02:06 PM [vite] Internal server error: Missing "./preview.js" specifier in "@storybook/react" package
  Plugin: vite:import-analysis

My stories are well discovered and listed, but the preview is showing an infinite circle loader.

I tried to create a new web app in react/ts with vite.

yarn create vite my-app --template react-ts

Then I integrated storybook by simply running:

npx sb init --builder @storybook/builder-vite

I have the following dev dependencies:

    "@storybook/addon-essentials": "^7.0.17",
    "@storybook/addon-interactions": "^7.0.17",
    "@storybook/addon-links": "^7.0.17",
    "@storybook/blocks": "^7.0.17",
    "@storybook/builder-vite": "^7.0.17",
    "@storybook/react": "^7.0.17",
    "@storybook/react-vite": "^7.0.17",
    "@storybook/testing-library": "^0.0.14-next.2",

    "storybook": "^7.0.17",
    "typescript": "^5.0.2",
    "vite": "^4.3.9"

I haven't found any solution, nowhere. Does Anyone here encountered the same?

Many thanks for your help

答案1

得分: 1

我遇到了相同的问题,经过一些调查,我发现了一个 GitHub 问题,确认了这个包中存在一个 bug:https://github.com/storybookjs/storybook/issues/23338 。

将 vite 升级到 v4.4.1,这对我解决了这个问题。

英文:

I had the same issue, and after some digging found a GitHub issue for it that confirms there is a bug in the package: https://github.com/storybookjs/storybook/issues/23338 .

Upgrade vite to v4.4.1, that solved the issue for me.

huangapple
  • 本文由 发表于 2023年7月6日 22:21:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629824.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定