Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify storybook path #1748

Closed
xareelee opened this issue Aug 27, 2017 · 3 comments
Closed

specify storybook path #1748

xareelee opened this issue Aug 27, 2017 · 3 comments

Comments

@xareelee
Copy link

I have multiple React Native apps in one monorepo:

monorepo/
 |-- package.json
 |-- apps/
      |-- FirstReactNativeApp/
      |     |-- storybook
      |-- SecondReactNativeApp/
      |     |-- storybook

when I use yarn storybook, it search and use the scripts in my package.json:

{
  "scripts": {
    "storybook": "storybook start -p 7007",
  }
}

but it shows errors in my console:

Scanning 1106 folders for symlinks in {path_to_root_project}/node_modules (19ms)

React Native Storybook started on => http://localhost:7007/

Scanning 1106 folders for symlinks in {path_to_root_project}/node_modules (25ms)

ENOENT: no such file or directory, stat '{path_to_root_project}/storybook'

webpack built 9c91edb89274e4fcca8d in 2967ms

How can I specify the path to the storybook/ folder I want to pack and launch?

For example:

// for first app
storybook start -p 7007 --folder apps/FirstReactNativeApp/storybook

// for second app
storybook start -p 7007 --folder apps/SecondReactNativeApp/storybook
@danielduan
Copy link
Member

you can set your package.json in apps/FirstReactNativeApp to do storybook start -p 7007. same with the other app.

then in your root package.json, you can have something like

scripts: {
  start-storybook-a: 'cd apps/FirstReactNativeApp && yarn storybook',
  ...
}

@xareelee
Copy link
Author

I use lerna for monorepo. I install storybook in the root package.json for all projects, not app's package.json.

monorepo/
 |-- package.json                    ## add storybook devDependency here
 |-- apps/
      |-- FirstReactNativeApp/
      |     |-- package.json
      |     |-- storybook
      |-- SecondReactNativeApp/
      |     |-- package.json
      |     |-- storybook

When I ran yarn storybook to execute the npm script storybook start -p 7007 under an app project, it doesn't find the storybook command in the node_modules of that app project.

@danielduan
Copy link
Member

danielduan commented Aug 28, 2017

You should be using lerna to start storybook then:
https://github.com/lerna/lerna#run

lerna run --scope FirstReactNativeApp storybook and have the above storybook command in the scripts for each react-native app directory

Please reopen if there's still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants