[英]Storybook install with react
I tried running npm run storybook after installing it for the first time on my new create-react-app application and I am getting this error.第一次在我的新 create-react-app 应用程序上安装 npm run storybook 后,我尝试运行它,但出现此错误。 Anybody know how to fix this ?
有人知道如何解决这个问题吗?
$ npm run storybook
> mystorybookapp@0.1.0 storybook
> start-storybook -p 6006 -s public
info @storybook/react v6.4.22
info
(node:19248) DeprecationWarning: --static-dir CLI flag is deprecated, see:
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
(Use `node --trace-deprecation ...` to show where the warning was created)
info => Loading presets
info => Serving static files from ./public at /
ERR! TypeError: details.family.toLowerCase is not a function
ERR! at C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:385:39
ERR! at Array.filter (<anonymous>)
ERR! at C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:384:37
ERR! at Array.map (<anonymous>)
ERR! at ip.address (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:379:37)
ERR! at getServerAddresses (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\utils\server-address.js:20:55)
ERR! at storybookDevServer (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\dev-server.js:91:67)
ERR! at async buildDevStandalone (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\build-dev.js:115:31)
ERR! at async buildDev (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\build-dev.js:161:5)
ERR! TypeError: details.family.toLowerCase is not a
function
ERR! at C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:385:39
ERR! at Array.filter (<anonymous>)
ERR! at C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:384:37
ERR! at Array.map (<anonymous>)
ERR! at ip.address (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\ip\lib\ip.js:379:37)
ERR! at getServerAddresses (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\utils\server-address.js:20:55)
ERR! at storybookDevServer (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\dev-server.js:91:67)
ERR! at async buildDevStandalone (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\build-dev.js:115:31)
ERR! at async buildDev (C:\Users\HP\Desktop\cra\react-storybook\mystorybookapp\node_modules\@storybook\core-server\dist\cjs\build-dev.js:161:5)
WARN Broken build, fix the error above.
WARN You may need to refresh the browser.
It's a super annoying issue I just faced too.这也是我刚刚遇到的一个超级烦人的问题。 So in order to eliminate this silly
static-dir
issue所以为了消除这个愚蠢
static-dir
问题
-s public
from the scripts-s public
from this由此
"scripts": {
"test": "react-scripts test",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
to this对此
"scripts": {
"test": "react-scripts test",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
staticDirs: ["../public"],
in your .storybook/main.js
like this:.storybook/main.js
中设置staticDirs: ["../public"],
如下所示:module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/preset-create-react-app"
],
"framework": "@storybook/react",
"core": {
"builder": "@storybook/builder-webpack5"
},
staticDirs: ["../public"]
}
more info can be found here: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag更多信息可以在这里找到: https ://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.