To Reproduce
Steps to reproduce the behavior:
Here is the exception:
*$ npx -p @storybook/cli sb init --type angular sb init -
"Adding storybook support to your "Angular" app
Error: Could not find a default project in your Angular workspace. Add a project and re-run the installation. at default (/Users/jonathan.ohayon/.npm/_npx/59743/lib/node_modules/@storybook/cli/generators/ANGULAR/index.js:67:11)"
cc @yannbf
Hey @jonathanohayon26, sorry that you're experiencing issues with Storybook.
Could you please check in your angular.json if there is a property called "defaultProject", and that it's correctly set? It's set by default when you initiate your app using angular CLI. It should look like this:
{
...
"projects": {
"my-project": {},
"my-project-e2e": {}
},
"defaultProject": "my-project", // <--- here!
"schematics": {
...
}
}
Hey @yannbf
The angular.json is correctly set with the "defaultProject": "my-project", // <--- here!
I simply created a new app angular 9 with cli and run "npx -p @storybook/cli sb init --type angular" as mentioned in the doc.
It is a pity that every new project in angular will meet this issue.
Thanks
That's pretty odd. I created two new apps with angular CLI, versions 9 and 10, then in each I ran npx -p @storybook/cli sb init --type angular (by the way --type is optional, the cli should be able to detect that you're using an angular project), and the installation was successful. My suspicion is that maybe you ran the storybook install command in a different folder than the root folder of your project.
As reference, I just pushed the project example with angular 9 + storybook for you at: https://github.com/yannbf/angular9-storybook-example
Hey @yannbf , I started from scratch, it works! Thanks
@yannbf I have experienced the same and in my case the issue was that I was not in the root directory. Thanks to the suggestion in your comment I was able to run the command successfully. Maybe it is worth a note in the docs.