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

npx is slow because @storybook/cli isn't added to package.json #13464

Closed
peey opened this issue Dec 16, 2020 · 4 comments
Closed

npx is slow because @storybook/cli isn't added to package.json #13464

peey opened this issue Dec 16, 2020 · 4 comments

Comments

@peey
Copy link

peey commented Dec 16, 2020

Describe the bug
Following the guide at https://storybook.js.org/docs/vue/get-started/install, I issue npx sb init in a fresh vuejs project.

But if I try to issue any further commands, like npx sb info, the commands run very slow, because npm is fetching something.

Issuing npm install --save-dev @storybook/cli solves the issue.

System

(some info omitted, please mention if you really need it)

Info before the fix:

  Binaries:
    Node: 10.19.0 - /usr/bin/node
    npm: 6.14.4 - /usr/bin/npm
  npmPackages:
    @storybook/addon-actions: ^6.1.11 => 6.1.11
    @storybook/addon-essentials: ^6.1.11 => 6.1.11
    @storybook/addon-links: ^6.1.11 => 6.1.11
    @storybook/vue: ^6.1.11 => 6.1.11

After the fix


  Binaries:
    Node: 10.19.0 - /usr/bin/node
    npm: 6.14.4 - /usr/bin/npm
  npmPackages:
    @storybook/addon-actions: ^6.1.11 => 6.1.11
    @storybook/addon-essentials: ^6.1.11 => 6.1.11
    @storybook/addon-links: ^6.1.11 => 6.1.11
    @storybook/cli: ^6.1.11 => 6.1.11
    @storybook/vue: ^6.1.11 => 6.1.11

@peey
Copy link
Author

peey commented Dec 16, 2020

Suggestion: either init command should add cli to package.json as a dev dependency, or update docs to use npx -p

@gaetanmaisse
Copy link
Member

After having run npx sb init you shouldn't use storybook CLI much as it should have added 2 NPM scripts in your package.json:

{...
    "build-storybook": "build-storybook",
    "storybook": "start-storybook -p 9009"
}

You can then run npm run storybook or npm run build-storybook directly and don't need to add the CLI as a dependency.

@peey
Copy link
Author

peey commented Jan 13, 2021

Hi, I no longer remember where I tried this and I don't remember my motivation for issuing further commands like npx sb info. I think I might've tried something like npx sb --help which gave me information about existence of the info command.

If that is indeed a legitimate use which can't be serviced by existing binaries in node_modules (e.g. if there is no npx storybook-info then I'll suggest adding the package as dev dependency.

If you feel that those commands are not intended for regular usage, feel free to close the issue.

I do want to mention that since npx, it is a common workflow to execute node_modules binaries directly instead of first making it a script into package.json (I understand that for building and starting -- the two most common ops, you already make entries in package.json, but in case there are other operations...). So it might be a good idea to include binaries that can perform common operations.

@gaetanmaisse
Copy link
Member

If you feel that those commands are not intended for regular usage, feel free to close the issue.

Definitely not, it should be used to init/upgrade/(rerun some migration) Storybook, get some info needed to open an issue but not much more that's why we didn't include it in the deps automatically installed during initialization.
If you're using regularly a Storybook CLI let us know it could be a first clue for a new feature or a refactoring.

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