Storybook: Installation on a Yarn workspace falls back on npm while Yarn is installed

Created on 3 Dec 2019  路  3Comments  路  Source: storybookjs/storybook

Describe the bug
The packages that are set up using sb init are being installed via npm despite Yarn presence.

To Reproduce
Steps to reproduce the behavior:

  1. Install Yarn via Chocolatey
  2. Install @storybook/cli globally via Yarn
  3. Run sb init on an applicable project
  4. Observe installation

Expected behavior
Yarn could have installed the packages instead of npm.

System:

  System:
    OS: Windows 10 10.0.17134
    CPU: (4) x64 Intel(R) Core(TM) i3-7100 CPU @ 3.90GHz
  Binaries:
    Node: 12.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.19.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.10.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0

Additional Context:

Chocolatey version is 0.10.15 (output of choco --version)

The sample project had Lerna and Yarn workspaces integrated. The command was run in a Yarn workspaces.

cli feature request

Most helpful comment

@pocka I edited my report to include that the command was run in a Yarn workspace.

From the directory I ran the command on, there was no yarn.lock present, however there existed a yarn.lock file in a parent directory serving as the Yarn workspaces root. In my case, I ran sb init in /project-dir/packages/package-foo, while the yarn.lock was present in /project-dir.

All 3 comments

@Temoto-kun
Does your application have yarn.lock?
Storybook CLI uses Yarn only when ( there is yarn.lock file on the installation directory OR npm command is unavailable) AND yarn command is available. https://github.com/storybookjs/storybook/pull/3453#issuecomment-382891993

// pseudo code
useYarn = (has('yarn.lock') || !isAvailable('npm')) && isAvailable('yarn')

By the way, we should change the doc. It's quite confusable 馃槙

@pocka I edited my report to include that the command was run in a Yarn workspace.

From the directory I ran the command on, there was no yarn.lock present, however there existed a yarn.lock file in a parent directory serving as the Yarn workspaces root. In my case, I ran sb init in /project-dir/packages/package-foo, while the yarn.lock was present in /project-dir.

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-beta.21 containing PR #9104 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilyaulyanov picture ilyaulyanov  路  100Comments

bpeab picture bpeab  路  70Comments

hckhanh picture hckhanh  路  69Comments

Gongreg picture Gongreg  路  58Comments

joeruello picture joeruello  路  79Comments