UNPKG

2.14 kBMarkdownView Raw
1# Storybook CLI
2
3Storybook CLI (_Command Line Interface_) is the easiest way to add [Storybook](https://github.com/storybookjs/storybook) to your project.
4
5![Screenshot](docs/getstorybook.png)
6
7Go to your project and run:
8
9```sh
10cd my-app
11npx sb init
12```
13
14In addition to `init`, the CLI also has other commands:
15
16- `add` - add an addon and register it
17- `info` - print out system information for bug reports
18- `migrate` - run codemods to migrate your code
19
20See the command-line help with `-h` for details.
21
22---
23
24## [Yarn](https://github.com/yarnpkg/yarn) support
25
26The CLI supports yarn. If you have installed yarn in your system and your project has a `yarn.lock` file, it'll detect it and use `yarn` to install dependencies.
27
28If you don't want to use `yarn` always you can use the `--package-manager` option like this:
29
30```sh
31npx sb init --package-manager=npm
32```
33
34If you would like to force a particular version of yarn, you can use the `--package-manager` flag with a value of `yarn1` or `yarn2`.
35
36---
37
38## [PNPM](https://pnpm.io/) support
39
40The CLI supports pnpm. If you have installed pnpm in your system and your project has a `pnpm-lock.yaml` file, it'll detect it and use `pnpm` to install dependencies.
41
42If you don't have a lock file and would like to force pnpm to be used, you can use the `--package-manager` option like this:
43
44```sh
45npx sb init --package-manager=pnpm
46```
47
48---
49
50## [Flow](https://flow.org/) support
51
52It also supports flow files. By default, [jscodeshift](https://github.com/facebook/jscodeshift), the tool used to transform the source files, uses babel to read the files. To be able to transform any flow annotated file, you need to use the flow parser.
53
54```sh
55npx sb init --parser flow
56```
57
58For more information visit: [storybook.js.org](https://storybook.js.org)
59
60---
61
62## Manually specify project type
63
64If the CLI cannot detect your project type, it will ask you. You can also force it to use a particular project type:
65
66```sh
67npx sb init --type <type>
68```
69
70Where type is one of the project types defined in [project_types.ts](https://github.com/storybookjs/storybook/blob/next/code/lib/cli/src/project_types.ts)