Storybook: Yarn workspace @storybook/react not hoisted

Created on 4 Jan 2020  ยท  13Comments  ยท  Source: storybookjs/storybook

Describe the bug
I have a yarn workspace project. Running yarn workspace x storybook yields this error:

ERROR in ../node_modules/@storybook/addon-docs/dist/frameworks/react/config.js
Module not found: Error: Can't resolve '@storybook/react' in '/home/root_project_path/node_modules/@storybook/addon-docs/dist/frameworks/react'
 @ ../node_modules/@storybook/addon-docs/dist/frameworks/react/config.js 3:13-40
 @ ../node_modules/@storybook/addon-docs/react/config.js
 @ multi ../node_modules/@storybook/core/dist/server/common/polyfills.js ../node_modules/@storybook/core/dist/server/preview/globals.js ../node_modules/@storybook/addon-docs/dist/frameworks/common/../../../react/config.js ./.storybook/config.js ../node_modules/webpack-hot-middleware/client.js?reload=true&quiet=true

I am not too familiar with how Yarn decides what packages to hoist. I have everything except @storybook/react hoisted to my root folder.

What I have under my workspace x is like so:

โ”œโ”€โ”€ @babel
โ”‚ย ย  โ”œโ”€โ”€ core
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ lib
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ config
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ files
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ helpers
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ validation
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ tools
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ transformation
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ file
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ util
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ node_modules
โ”‚ย ย  โ”œโ”€โ”€ plugin-syntax-flow
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ lib
โ”‚ย ย  โ”œโ”€โ”€ plugin-transform-flow-strip-types
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ lib
โ”‚ย ย  โ”œโ”€โ”€ plugin-transform-react-constant-elements
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ lib
โ”‚ย ย  โ””โ”€โ”€ preset-flow
โ”‚ย ย      โ””โ”€โ”€ lib
โ”œโ”€โ”€ babel-plugin-named-asset-import
โ”œโ”€โ”€ debug
โ”‚ย ย  โ”œโ”€โ”€ dist
โ”‚ย ย  โ””โ”€โ”€ src
โ”œโ”€โ”€ ms
โ”œโ”€โ”€ source-map
โ”‚ย ย  โ”œโ”€โ”€ dist
โ”‚ย ย  โ””โ”€โ”€ lib
โ””โ”€โ”€ @storybook
    โ””โ”€โ”€ react
        โ”œโ”€โ”€ bin
        โ”œโ”€โ”€ dist
        โ”‚ย ย  โ”œโ”€โ”€ client
        โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ preview
        โ”‚ย ย  โ”œโ”€โ”€ demo
        โ”‚ย ย  โ””โ”€โ”€ server
        โ””โ”€โ”€ node_modules
            โ””โ”€โ”€ semver
                โ””โ”€โ”€ bin

To Reproduce
Steps to reproduce the behavior:

  1. Initialize storybook react under a yarn workspace x
  2. yarn workspace x storybook

Expected behavior
Runs without error

System:

Environment Info:

  System:
    OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
  Binaries:
    Node: 12.14.0 - /usr/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.13.4 - /usr/bin/npm
  Browsers:
    Chrome: 79.0.3945.88
    Firefox: 71.0
  npmPackages:
    @storybook/react: ^5.2.8 => 5.2.8 
  npmGlobalPackages:
    @storybook/cli: 5.2.8
compatibility with other tools has workaround inactive yarn / npm

Most helpful comment

@raroul there are bunch of yarn 2 related fixes that @gaetanmaisse has been working on, available in 6.0. hopefully these will make the workaround unnecessaruy.

All 13 comments

I have the same issue

So I got it resolved by removing the react-is from the workspace package.json. See if it helps.

@mckn I don't believe I have react-is installed though. I currently still have to use cd x && yarn storybook for it to work. Let me see if rerunning yarn upgrade works.

EDIT: It still didn't work.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Is nobody having the same problem with yarn package manager?

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Not hoisted here too, I'm investigating.

It seems that there is a bug with @storybook/react and workspaces. A workaround could be to disable hoisting for storybook in the root package.json of your workspace. No more errors after that for me.

More infos here: https://classic.yarnpkg.com/blog/2018/02/15/nohoist/

{
  "private": true,
  "workspaces": {
    "packages": [
      "*"
    ],
    "nohoist": [
      "@storybook",
      "**/@storybook",
      "**/@storybook/**"
    ]
  }
}

@raroul there are bunch of yarn 2 related fixes that @gaetanmaisse has been working on, available in 6.0. hopefully these will make the workaround unnecessaruy.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Any updates on this? @raroul works, but it would be good to have a real fix :)

@delucca we fixed some issues related to Storybook usage in a monorepo a few weeks ago, can you try the latest 6.1 alpha and let us know if you still face the issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maraisr picture maraisr  ยท  119Comments

Gongreg picture Gongreg  ยท  58Comments

moimikey picture moimikey  ยท  67Comments

joeruello picture joeruello  ยท  79Comments

bpeab picture bpeab  ยท  70Comments