Skip to content

Commit

Permalink
Merge pull request #26500 from storybookjs/valentin/use-npm-over-yarn…
Browse files Browse the repository at this point in the history
…1-while-init

CLI: Introduce package manager fallback for initializing Storybook in an empty directory with yarn1
(cherry picked from commit c0fdb3e)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Mar 19, 2024
1 parent 49c14ee commit ef0b71b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export async function doInitiate(
> {
const { packageManager: pkgMgr } = options;

const packageManager = JsPackageManagerFactory.getPackageManager({
let packageManager = JsPackageManagerFactory.getPackageManager({
force: pkgMgr,
});

Expand Down Expand Up @@ -276,6 +276,13 @@ export async function doInitiate(

// Check if the current directory is empty.
if (options.force !== true && currentDirectoryIsEmpty(packageManager.type)) {
// Initializing Storybook in an empty directory with yarn1
// will very likely fail due to different kind of hoisting issues
// which doesn't get fixed anymore in yarn1.
// We will fallback to npm in this case.
if (packageManager.type === 'yarn1') {
packageManager = JsPackageManagerFactory.getPackageManager({ force: 'npm' });
}
// Prompt the user to create a new project from our list.
await scaffoldNewProject(packageManager.type, options);

Expand Down

0 comments on commit ef0b71b

Please sign in to comment.