故事书(反应):找不到 main.js

Storybook (React): can't find main.js

我一直面临一个问题,即当我 运行 yarn storybook 时,新创建的故事书项目无法识别 main.js 文件。我在其他项目中使用过故事书,没有遇到任何问题。

我怀疑这可能与 main.js 文件的路径有关,其中目录名称中使用了方括号。这是 fivem 用来组织其资源的命名约定。

图像显示了我的 main.js 文件、项目结构和我在 运行 宁 yarn storybook 时收到的错误。

ERR! Error: No configuration files have been found in your configDir (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\.storybook).
ERR! Storybook needs either a "main" or "config" file.
ERR!     at validateConfigurationFiles (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\utils\validate-configuration-files.js:50:11)
ERR!     at loadCustomPresets (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\utils\load-custom-presets.js:19:62)
ERR!     at loadAllPresets (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\presets.js:310:105)
ERR!     at buildDevStandalone (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-server\dist\cjs\build-dev.js:98:48)
ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5)
ERR!     at async buildDev (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-server\dist\cjs\build-dev.js:147:5)
ERR!  Error: No configuration files have been found in your configDir (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\.storybook).
ERR! Storybook needs either a "main" or "config" file.
ERR!     at validateConfigurationFiles (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\utils\validate-configuration-files.js:50:11)
ERR!     at loadCustomPresets (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\utils\load-custom-presets.js:19:62)
ERR!     at loadAllPresets (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-common\dist\cjs\presets.js:310:105)
ERR!     at buildDevStandalone (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-server\dist\cjs\build-dev.js:98:48)
ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5)
ERR!     at async buildDev (C:\Users\adam_\Documents\dev\fivem\fxserver\txData\CFXDefault_943D47.base\resources\[UI]\react-fivem\web\node_modules\@storybook\core-server\dist\cjs\build-dev.js:147:5)

main.js

module.exports = {
  "stories": [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  "addons": [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/preset-create-react-app"
  ]
}

我的项目结构是否有问题导致了这个问题?

提前致谢

好的,在创建这个之后不久,我将我的 react-fivem 目录向上移动了几层,在 main.js 的路径中没有使用方括号,它开始正常。

我希望这对以后的人有用!