Storybook: CLI - create-react-library - 5.1 regression

Created on 16 May 2019  ·  5Comments  ·  Source: storybookjs/storybook

Describe the bug

Running storybook init (npx -p @storybook/cli@next sb init) on a project generated with create-react-library with next storybook version results with an error:

 • Adding storybook support to your "Create React App" based project                                                            
     TypeError: Cannot read property 'split' of undefined                                                                       
    at new Range (/home/mfolnovic/.npm/_npx/25246/lib/node_modules/@storybook/cli/node_modules/semver/semver.js:866:20)
    at outside (/home/mfolnovic/.npm/_npx/25246/lib/node_modules/@storybook/cli/node_modules/semver/semver.js:1408:11)
    at Function.gtr (/home/mfolnovic/.npm/_npx/25246/lib/node_modules/@storybook/cli/node_modules/semver/semver.js:1402:10)
    at gtr (/home/mfolnovic/.npm/_npx/25246/lib/node_modules/@storybook/cli/generators/REACT_SCRIPTS/index.js:42:14)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

Difference between what generates create-react-app and create-react-library is where it puts react-scripts dependency. create-react-app puts it in dependencies while create-react-library puts it in devDependencies.
It works if I move react-scripts dependency from devDependencies to dependenciesafter generating project with create-react-library.

It also works correctly with 5.0.11: npx -p @storybook/cli sb init.

To Reproduce
Steps to reproduce the behavior:

  1. npm install -g create-react-library
  2. create-react-library -s -t default test
  3. cd test
  4. npx -p @storybook/cli@next sb init

Expected behavior
It should work the same way as npx -p @storybook/cli sb init - without an error, generating files.

System:

  • OS: Linux (Arch Linux)
  • Device: Thinkpad P50
  • Framework: React
  • Version: v5.1.0-beta.1
bug cli high priority

Most helpful comment

This seems like a simple fix, i'll take this one for you @mrmckeb . PR incoming

All 5 comments

@mrmckeb It looks like you added this line here and @MikaelCarpenter touched it again when adding the installation improvements (but I don't think that's the problem):
https://github.com/storybooks/storybook/commit/074d0f36da88d740167b1a033d63396e6f04af0b#diff-9db699d9952076f9824f81e3076cf80c

Would you mind taking a look at this? I'm pretty sure what's going on is that react-scripts is installed in a subdirectory but not in the main directory in create-react-library. Or that it's installed as a devDependency.... Thanks!! 🙏

This seems like a simple fix, i'll take this one for you @mrmckeb . PR incoming

Thanks @MikaelCarpenter! Can this be closed off now?

@mrmckeb will close when it's released

Jeepers creepers!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-rc.0 containing PR #6815 that references this issue. Upgrade today to try it out!

Because it's a pre-release you can find it on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

Was this page helpful?
0 / 5 - 0 ratings