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

CLI: Fix storybook dev after storybook init via subprocess #23144

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Jun 20, 2023

Closes #

What I did

When executing dev directly in Storybook init, there is a possibility of having the following issue:

WARN   Failed to load preset: "@storybook/react-vite/preset"
ERR! Error: Cannot find module '@storybook/react-vite/preset'
ERR! Require stack:
ERR! - /Users/xyz/.npm/_npx/eb8bf615e50a412a/node_modules/@storybook/core-common/dist/index.js
ERR! - /Users/xyz/.npm/_npx/eb8bf615e50a412a/node_modules/@storybook/telemetry/dist/index.js
ERR! - /Users/xyz/.npm/_npx/eb8bf615e50a412a/node_modules/@storybook/cli/dist/generate.js

This happens because of the location of the packages in node_modules. By spawning a subprocess, this problem goes away as the process executes in the current working directory instead, where the node_modules should be present and correctly resolved.

How to test

  1. Build packages and start local registry
  2. Set your global registry to: npm config set registry http://localhost:6001
  3. Run init e.g. src/lib/cli/bin/index.js init in a react-vite project
  4. Things should work

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@shilman shilman changed the title CLI: Run storybook dev after storybook init via subprocess CLI: Fix storybook dev after storybook init via subprocess Jun 20, 2023
@shilman shilman merged commit c739d02 into next Jun 20, 2023
@shilman shilman deleted the fix/init-after-dev branch June 20, 2023 13:40
@github-actions github-actions bot mentioned this pull request Jun 20, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants