storybook/cli gives an error when initiating a repo with $ getstorybook.
:~/blog/taskbox$ npx -p @storybook/cli getstorybook
npx: installed 312 in 22.043s
getstorybook - the simplest way to add a storybook to your project.
• Detecting project type. ✓
• Adding storybook support to your "Create React App" based project
../../package.json: No license field
../../package.json: No license field
../../package.json: No license field
Seems like
getstorybookfails ifpackage.jsonat/home/userdoes not have alicesefield.
sudo npm i -g @storybook/cligetstorybookstorybook/cli: 3.4.2It works fine if I add a license field in package.json at home dir.
I believe this is a warning thrown by npm.
If you do npm install @storybook/react --save for example in the same directory, you should get the same warning.
Does this prevent getstorybook from completing the install?
I personally don't think we should get into the business of catching npm warnings as there are many more such as No repository field, No description. The message is clear and the error issimple enough to fix.
@danielduan thanks.
Does this prevent getstorybook from completing the install?
Yes it does prevent getstorybook from completing the install.
package.jsonlicense field.{
"dependencies": {
"create-react-app": "^1.5.2",
"gatsby": "^1.9.240",
"gatsby-cli": "^1.1.48",
"global": "^4.3.2",
"roast-my-deps": "^2.0.0"
}
}
```
* After ```license``` field.
{
"license": "MIT",
"dependencies": {
"create-react-app": "^1.5.2",
"gatsby": "^1.9.240",
"gatsby-cli": "^1.1.48",
"global": "^4.3.2",
"roast-my-deps": "^2.0.0"
}
}
```
terminal before and after license field.
If you or someone would like to open a PR to fix this, please do.
I would like to give this a try. I assume the intended behaviour is to install regardless of a license field, @danielduan?
I'm not quite sure how to tackle this problem.
After mimicking error locally, I looked into the code and got to the point where https://github.com/storybooks/storybook/blob/master/lib/cli/bin/generate.js#L98 is called, which leads me to https://github.com/storybooks/storybook/blob/master/lib/cli/lib/helpers.js#L86. That should be the last line logged, as there is no red or green chalk added before the repeated No license field. I assume it exits on https://github.com/storybooks/storybook/blob/bc6c66d1784cb027c6e4b924e8eb7c2523d5423b/lib/cli/bin/generate.js#L181, but I can't quite figure out where it catches the exception from.
Am I looking at the wrong place or missing something?
@danielduan
It seems that here it goes to the error if the license is not specified.
https://github.com/storybooks/storybook/blob/master/lib/cli/lib/latest_version.js#L8
Can u guide me to fix this issue??
@Keraito if this finding helps you to fix ,feel free to.
That’s weird that it checks package.json in your home directory. Unless you have no package.json in the directory where you run getstorybook. You might want to create it first using npm init
@Keraito @Hypnosphi
Did this issue get fixed.I was trying today on 3.4.3version of the cli and this went through with out any errors.I understand that @Keraito code is not merged.But the issue is not there anymore.
Please confirm
@sunilhari can you check whether
getstorybook@Hypnosphi
Sorry some way it was using npm.Yeah the issue still exist.yarn.lock was not there
released as 3.4.4
It fixed my problem
sudo npm i -g @storybook/cli
sb init
Most helpful comment
@Hypnosphi
Sorry some way it was using npm.Yeah the issue still exist.yarn.lock was not there