由于角度故事书中的“类型‘serveroptions’不是通用的”,无法在角度项目中运行故事书

Ani*_*Das 4 angular storybook angular-storybook angular16

我安装了故事书,npx sb init但是当尝试运行故事书时in angular 16出现以下错误。这些错误并不指向项目中的任何特定代码,而是指向节点和角度中的一些随机代码。

\n
\n

变量 'AbortSignal' 的类型必须为 '{ new (): AbortSignal; 原型:AbortSignal;中止(原因?:任何):AbortSignal;超时(毫秒:数字):AbortSignal;}',但这里有类型 '{ new (): AbortSignal; 原型:AbortSignal;}

\n
\n
\n

类型“ServerOptions”不是通用的

\n
\n

这是详细的错误消息:

\n
\nError: node_modules/@types/node/globals.d.ts:72:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'.\n\n72 declare var AbortSignal: {\n               ~~~~~~~~~~~\n\n  node_modules/typescript/lib/lib.dom.d.ts:2090:13\n    2090 declare var AbortSignal: {\n                     ~~~~~~~~~~~\n    'AbortSignal' was also declared here.\n\n    at addError (/node_modules/@ngtools/webpack/src/ivy/diagnostics.js:31:27)\n    at /node_modules/@ngtools/webpack/src/ivy/diagnostics.js:18:9\n    at AngularWebpackPlugin.updateJitProgram (/node_modules/@ngtools/webpack/src/ivy/plugin.js:371:5)\n    at AngularWebpackPlugin.setupCompilation (/node_modules/@ngtools/webpack/src/ivy/plugin.js:152:87)\n    at /node_modules/@ngtools/webpack/src/ivy/plugin.js:100:14\n    at Hook.eval [as call] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:14:14), <anonymous>:24:1)\n    at Hook.CALL_DELEGATE [as _call] (/node_modules/tapable/lib/Hook.js:11:15)\n    at Compiler.newCompilation (/node_modules/webpack/lib/Compiler.js:884:32)\n    at /node_modules/webpack/lib/Compiler.js:924:32\n    at _next0 (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:28:14), <anonymous>:41:1)\nError: node_modules/webpack/types.d.ts:6157:5 - error TS2315: Type 'ServerOptions' is not generic.\n\n6157   | ServerOptionsImport<typeof IncomingMessage>\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n    at addError (/node_modules/@ngtools/webpack/src/ivy/diagnostics.js:31:27)\n    at /node_modules/@ngtools/webpack/src/ivy/diagnostics.js:18:9\n    at AngularWebpackPlugin.updateJitProgram (/node_modules/@ngtools/webpack/src/ivy/plugin.js:371:5)\n    at AngularWebpackPlugin.setupCompilation (/node_modules/@ngtools/webpack/src/ivy/plugin.js:152:87)\n    at /node_modules/@ngtools/webpack/src/ivy/plugin.js:100:14\n    at Hook.eval [as call] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:14:14), <anonymous>:24:1)\n    at Hook.CALL_DELEGATE [as _call] (/node_modules/tapable/lib/Hook.js:11:15)\n    at Compiler.newCompilation (/node_modules/webpack/lib/Compiler.js:884:32)\n    at /node_modules/webpack/lib/Compiler.js:924:32\n    at _next0 (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:28:14), <anonymous>:41:1)\nError: node_modules/webpack/types.d.ts:10934:41 - error TS2315: Type 'ServerOptions' is not generic.\n\n10934 > = SecureContextOptions & TlsOptions & ServerOptionsImport<Request, Response>;\n                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n    at addError (/node_modules/@ngtools/webpack/src/ivy/diagnostics.js:31:27)\n    at /node_modules/@ngtools/webpack/src/ivy/diagnostics.js:18:9\n    at AngularWebpackPlugin.updateJitProgram (/node_modules/@ngtools/webpack/src/ivy/plugin.js:371:5)\n    at AngularWebpackPlugin.setupCompilation (/node_modules/@ngtools/webpack/src/ivy/plugin.js:152:87)\n    at /node_modules/@ngtools/webpack/src/ivy/plugin.js:100:14\n    at Hook.eval [as call] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:14:14), <anonymous>:24:1)\n    at Hook.CALL_DELEGATE [as _call] (/node_modules/tapable/lib/Hook.js:11:15)\n    at Compiler.newCompilation (/node_modules/webpack/lib/Compiler.js:884:32)\n    at /node_modules/webpack/lib/Compiler.js:924:32\n    at _next0 (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:28:14), <anonymous>:41:1)\n\n\xe2\x9c\x94 Would you like to help improve Storybook by sending anonymous crash reports? \xe2\x80\xa6 yes\nBroken build, fix the error above.\nYou may need to refresh the browser.\n\n
Run Code Online (Sandbox Code Playgroud)\n

Ani*_*Das 6

问题是我正在使用node 18.12.1 but "@types/node": "17.0.23"` 安装在我的开发依赖项中。

当我更新后,"@types/node": "18.16.15"所有问题都消失了,并且能够在浏览器中运行和查看故事书