英文:
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
-
你需要首先尝试删除
node_modules
和package-lock.json
文件,然后再试一次。 -
如果那不起作用,然后:
仅删除
C:\Users\yourUserName\AppData\Roaming\npm
和
C:\Users\yourUserName\AppData\Roaming\npm-cache
- 这也可能是因为网络故障,只需在现有项目的根目录中运行以下命令:
英文:
-
You need to first try deleting
node_modules
andpackage-lock.json
file and the try again . -
if that does not work then :
JUST Delete
C:\Users\yourUserName\AppData\Roaming\npm
AND
C:\Users\yourUserName\AppData\Roaming\npm-cache
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论