1 | # Storybook CLI
|
2 |
|
3 | Storybook 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 |
|
7 | Go to your project and run:
|
8 |
|
9 | ```sh
|
10 | cd my-app
|
11 | npx sb init
|
12 | ```
|
13 |
|
14 | In 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 |
|
20 | See the command-line help with `-h` for details.
|
21 |
|
22 | ---
|
23 |
|
24 | ## [Yarn](https://github.com/yarnpkg/yarn) support
|
25 |
|
26 | The 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 |
|
28 | If you don't want to use `yarn` always you can use the `--package-manager` option like this:
|
29 |
|
30 | ```sh
|
31 | npx sb init --package-manager=npm
|
32 | ```
|
33 |
|
34 | If 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 |
|
40 | The 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 |
|
42 | If 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
|
45 | npx sb init --package-manager=pnpm
|
46 | ```
|
47 |
|
48 | ---
|
49 |
|
50 | ## [Flow](https://flow.org/) support
|
51 |
|
52 | It 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
|
55 | npx sb init --parser flow
|
56 | ```
|
57 |
|
58 | For more information visit: [storybook.js.org](https://storybook.js.org)
|
59 |
|
60 | ---
|
61 |
|
62 | ## Manually specify project type
|
63 |
|
64 | If 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
|
67 | npx sb init --type <type>
|
68 | ```
|
69 |
|
70 | Where 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)
|