我需要帮助解决storybook init的错误。

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

I need help resolving an error with storybook init

问题

我尝试在我建立的组件库中初始化Storybook,但在运行命令时遇到错误。

我已经设置了一个包含库和测试应用程序的工作区。我正在尝试添加Storybook,所以我在Windows机器的工作区根目录上运行 npx storybook@latest init。我的Storybook版本是7.0.11

我收到的错误是:

SyntaxError: 位置5133处的JSON中出现意外的}标记
at JSON.parse (<anonymous>)
at new AngularJSON (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:50:689)
at generator (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:50:3150)
at async installStorybook (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:332:791)
at async doInitiate (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:337:707)
at async withTelemetry (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\core-server\dist\index.js:35:3422)
at async initiate (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:348:109)
英文:

I am trying to initialize the storybook in a component library I've built, but I am running into issues with the command returning an error.

I have set up my workspace with a library and a test application. I am trying to add storybook, so I'm running npx storybook@latest init at my workspace root directory on a Windows machine. I have storybook 7.0.11

The error I get is this:

SyntaxError: Unexpected token } in JSON at position 5133
at JSON.parse (<anonymous>)
at new AngularJSON (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:50:689)
at generator (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:50:3150)
at async installStorybook (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:332:791)
at async doInitiate (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:337:707)
at async withTelemetry (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\core-server\dist\index.js:35:3422)
at async initiate (C:\Users\{}\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:348:109)

答案1

得分: 0

  1. 你需要首先尝试删除 node_modulespackage-lock.json 文件,然后再试一次。

  2. 如果那不起作用,然后:

仅删除

C:\Users\yourUserName\AppData\Roaming\npm

C:\Users\yourUserName\AppData\Roaming\npm-cache
  1. 这也可能是因为网络故障,只需在现有项目的根目录中运行以下命令:
英文:
  1. You need to first try deleting node_modules and package-lock.json file and the try again .

  2. if that does not work then :

JUST Delete

C:\Users\yourUserName\AppData\Roaming\npm

AND

C:\Users\yourUserName\AppData\Roaming\npm-cache
  1. It can also be due to network failure and just Run this inside your existing project’s root directory:

答案2

得分: 0

在我的 angular.json 文件中有一个尾随逗号,导致了这个错误。

英文:

There was a trailing comma in my angular.json file, which caused this error.

huangapple
  • 本文由 发表于 2023年5月14日 11:39:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245712.html
匿名

发表评论

匿名网友

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

确定