Yarn workspace @storybook/react not hoisted
See original GitHub issueDescribe 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:
node_modules
βββ @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:
- Initialize storybook react under a yarn workspace
x
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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15 (3 by maintainers)
Top Results From Across the Web
nohoist in Workspaces | Yarn Blog
nohoist patterns. β**/react-nativeβ: this tells yarn not to hoist the react-native package itself, no matter where it is. (shallow).
Read more >reactjs - How to figure out why package is not hoisted in yarn3 ...
I'm using yarn 3 monorepo and for some reason, react-dom package is not hoisted properly: The same version of react-dom is duplicated acrossΒ ......
Read more >The Case for Monorepos: A sane Workspace Setup (Part 2)
Learn how to setup dev tooling in a monorepo, run tasks efficiently, release multiple packages and overcome common DevOps challenges.
Read more >A guide through The Wild Wild West of setting up a mono repo ...
Setting up a mono repo from scratch. We will be using TypeScript, Yarn workspaces, Lerna, and Jest. The release of the packages will...
Read more >Today I Learned: Lerna and Yarn Workspaces - Julian Burr
Popular examples for the use of monorepos (and yarn workspaces) are React, Babel, Storybook and a lot of others. Yarn workspaces helps you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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/
@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.