storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.7k stars 9.33k forks source link

@storybook/vue3 can't be launched with yarn2, requires react #15450

Closed Ashimriat closed 1 year ago

Ashimriat commented 3 years ago

Describe the bug I'm using storybook@vue3 in my project, originally made with npm, and trying to adapt it to yarn2 ("berry"). Current setup runs perfectly with npm, but then I try to launch "start-storybook" with yarn it just fails with following (full log):

PS C:\Users\ya\Desktop\projects\web-editor-client> yarn run storybook:server
info @storybook/vue3 v6.3.2
info 
info => Loading presets
WARN   Failed to load preset: "C:\\Users\\ya\\Desktop\\projects\\web-editor-client\\.yarn\\$$virtual\\@storybook-manager-webpack5-virtual-0d65fcb9a2\\0\\cache\\@storybook-manager-webpack5-npm-6.3.2-e0d5734b2d-8dc042f35f.zip\\node_modules\\@storybook\\manager-webpack5\\dist\\cjs\\presets\\manager-preset.js"
ERR! Error: @storybook/ui tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.
ERR! 
ERR! Required package: react (via "react\package.json")
ERR! Required by: @storybook/ui@virtual:ad2fef2d647b9eb53395f025babf3cf44cd42ca4884db671170232c5e4fac7f2d5e3a547a286af264db1085a9ca26bf5a081bc70e0ca8436bf2fd19d49d8f559#npm:6.3.2 (via C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\)      
ERR! Ancestor breaking the chain: web-editor-client@workspace:.
ERR! 
ERR!
ERR! Require stack:
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\noop.js
ERR!     at internalTools_makeError (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36689:34)
ERR!     at resolveToUnqualified (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37613:23)
ERR!     at resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37746:29)
ERR!     at Object.resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37824:26)
ERR!     at Function.external_module_.Module._resolveFilename (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36922:34)
ERR!     at resolveFileName (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:29:39)        
ERR!     at resolveFrom (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:43:9)
ERR!     at module.exports (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:46:47)
ERR!     at Object.<anonymous> (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\paths.js:17:18)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36818:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:92:18)
ERR!     at Object.<anonymous> (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-manager-webpack5-virtual-0d65fcb9a2\0\cache\@storybook-manager-webpack5-npm-6.3.2-e0d5734b2d-8dc042f35f.zip\node_modules\@storybook\manager-webpack5\dist\cjs\manager-webpack.config.js:48:38)
ERR!  Error: @storybook/ui tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.
ERR!
ERR! Required package: react (via "react\package.json")
ERR! Required by: @storybook/ui@virtual:ad2fef2d647b9eb53395f025babf3cf44cd42ca4884db671170232c5e4fac7f2d5e3a547a286af264db1085a9ca26bf5a081bc70e0ca8436bf2fd19d49d8f559#npm:6.3.2 (via C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\)      
ERR! Ancestor breaking the chain: web-editor-client@workspace:.
ERR!
ERR!
ERR! Require stack:
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\noop.js
ERR!     at internalTools_makeError (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36689:34)
ERR!     at resolveToUnqualified (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37613:23)
ERR!     at resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37746:29)
ERR!     at Object.resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37824:26)
ERR!     at Function.external_module_.Module._resolveFilename (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36922:34)
ERR!     at resolveFileName (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:29:39)        
ERR!     at resolveFrom (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:43:9)
ERR!     at module.exports (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\cache\resolve-from-npm-5.0.0-15c9db4d33-0d29fc7012.zip\node_modules\resolve-from\index.js:46:47)
ERR!     at Object.<anonymous> (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-ui-virtual-648fa56735\0\cache\@storybook-ui-npm-6.3.2-54401a10c1-3374416ff8.zip\node_modules\@storybook\ui\paths.js:17:18)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36818:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:92:18)
ERR!     at Object.<anonymous> (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-manager-webpack5-virtual-0d65fcb9a2\0\cache\@storybook-manager-webpack5-npm-6.3.2-e0d5734b2d-8dc042f35f.zip\node_modules\@storybook\manager-webpack5\dist\cjs\manager-webpack.config.js:48:38)
info Found existing addon "@storybook/addon-docs", skipping.
info => Loading 1 config file in "C:\Users\ya\Desktop\projects\web-editor-client\storybook"
info => Loading 9 other files in "C:\Users\ya\Desktop\projects\web-editor-client\storybook"
info => Adding stories defined in "C:\Users\ya\Desktop\projects\web-editor-client\storybook\main.js"
ERR! Error: @storybook/builder-webpack5 tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.
ERR!
ERR! Required package: react (via "react\package.json")
ERR! Required by: @storybook/builder-webpack5@virtual:9ebf478e02a27e8c80ac571e5b1785aa85fb1429e4207acfb69904bf84fd5e63df50d50479f75e9d127146698b964d12f67558abe3af2f889cfadc828f08e4ab#npm:6.3.2 (via C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\)
ERR! Ancestor breaking the chain: web-editor-client@workspace:.
ERR!
ERR!
ERR! Require stack:
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\presets\preview-preset.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-common-virtual-3aaea65e1b\0\cache\@storybook-core-common-npm-6.3.2-d6ede51b83-22e14acc56.zip\node_modules\@storybook\core-common\dist\cjs\presets.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-common-virtual-3aaea65e1b\0\cache\@storybook-core-common-npm-6.3.2-d6ede51b83-22e14acc56.zip\node_modules\@storybook\core-common\dist\cjs\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-virtual-399d0ed62d\0\cache\@storybook-core-npm-6.3.2-3239ca1697-07c43156f9.zip\node_modules\@storybook\core\dist\cjs\server.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-virtual-399d0ed62d\0\cache\@storybook-core-npm-6.3.2-3239ca1697-07c43156f9.zip\node_modules\@storybook\core\server.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-vue3-virtual-c68fb623c8\0\cache\@storybook-vue3-npm-6.3.2-084dd883c4-deaea89a72.zip\node_modules\@storybook\vue3\dist\cjs\server\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-vue3-virtual-c68fb623c8\0\cache\@storybook-vue3-npm-6.3.2-084dd883c4-deaea89a72.zip\node_modules\@storybook\vue3\bin\index.js
ERR!     at internalTools_makeError (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36689:34)
ERR!     at resolveToUnqualified (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37613:23)
ERR!     at resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37746:29)
ERR!     at Object.resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37824:26)
ERR!     at Function.external_module_.Module._resolveFilename (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36922:34)
ERR!     at Function.resolve (internal/modules/cjs/helpers.js:98:19)
ERR!     at _default (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js:188:46)
ERR!     at processTicksAndRejections (internal/process/task_queues.js:95:5)
ERR!     at async Object.start (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:76:16)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\dev-server.js:123:28)
ERR!     at async buildDevStandalone (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\build-dev.js:112:31)
ERR!     at async buildDev (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\build-dev.js:154:5)
ERR!  Error: @storybook/builder-webpack5 tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.
ERR!
ERR! Required package: react (via "react\package.json")
ERR! Required by: @storybook/builder-webpack5@virtual:9ebf478e02a27e8c80ac571e5b1785aa85fb1429e4207acfb69904bf84fd5e63df50d50479f75e9d127146698b964d12f67558abe3af2f889cfadc828f08e4ab#npm:6.3.2 (via C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\)
ERR! Ancestor breaking the chain: web-editor-client@workspace:.
ERR!
ERR!
ERR! Require stack:
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\presets\preview-preset.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-common-virtual-3aaea65e1b\0\cache\@storybook-core-common-npm-6.3.2-d6ede51b83-22e14acc56.zip\node_modules\@storybook\core-common\dist\cjs\presets.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-common-virtual-3aaea65e1b\0\cache\@storybook-core-common-npm-6.3.2-d6ede51b83-22e14acc56.zip\node_modules\@storybook\core-common\dist\cjs\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-virtual-399d0ed62d\0\cache\@storybook-core-npm-6.3.2-3239ca1697-07c43156f9.zip\node_modules\@storybook\core\dist\cjs\server.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-virtual-399d0ed62d\0\cache\@storybook-core-npm-6.3.2-3239ca1697-07c43156f9.zip\node_modules\@storybook\core\server.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-vue3-virtual-c68fb623c8\0\cache\@storybook-vue3-npm-6.3.2-084dd883c4-deaea89a72.zip\node_modules\@storybook\vue3\dist\cjs\server\index.js
ERR! - C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-vue3-virtual-c68fb623c8\0\cache\@storybook-vue3-npm-6.3.2-084dd883c4-deaea89a72.zip\node_modules\@storybook\vue3\bin\index.js
ERR!     at internalTools_makeError (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36689:34)
ERR!     at resolveToUnqualified (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37613:23)
ERR!     at resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37746:29)
ERR!     at Object.resolveRequest (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:37824:26)
ERR!     at Function.external_module_.Module._resolveFilename (C:\Users\ya\Desktop\projects\web-editor-client\.pnp.js:36922:34)
ERR!     at Function.resolve (internal/modules/cjs/helpers.js:98:19)
ERR!     at _default (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js:188:46)
ERR!     at processTicksAndRejections (internal/process/task_queues.js:95:5)
ERR!     at async Object.start (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-builder-webpack5-virtual-b05643d43a\0\cache\@storybook-builder-webpack5-npm-6.3.2-ee0928256e-09927618cf.zip\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:76:16)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\dev-server.js:123:28)
ERR!     at async buildDevStandalone (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\build-dev.js:112:31)
ERR!     at async buildDev (C:\Users\ya\Desktop\projects\web-editor-client\.yarn\$$virtual\@storybook-core-server-virtual-f324dba05e\0\cache\@storybook-core-server-npm-6.3.2-7c882f9734-a6d6d2eeab.zip\node_modules\@storybook\core-server\dist\cjs\build-dev.js:154:5)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

To me it seems very odd that vue-oriented version of project has a react as a dependency, without which its jsut cant be launched. Gladle waiting for you assistance.

To Reproduce dependencies part of package.json

  "license": "MIT",
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "@fortawesome/vue-fontawesome": "^3.0.0-4",
    "reflect-metadata": "^0.1.13",
    "vue": "^3.1.1",
    "vue-property-decorator": "^10.0.0-rc.3",
    "vuex": "^4.0.2",
    "vuex-class-modules": "^1.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/node": "^7.14.7",
    "@babel/preset-env": "^7.14.7",
    "@storybook/addon-actions": "^6.3.2",
    "@storybook/addon-docs": "^6.3.2",
    "@storybook/addon-essentials": "^6.3.2",
    "@storybook/addon-links": "^6.3.2",
    "@storybook/addon-storyshots": "^6.3.2",
    "@storybook/builder-webpack5": "^6.3.2",
    "@storybook/cli": "^6.3.2",
    "@storybook/manager-webpack5": "^6.3.2",
    "@storybook/vue3": "^6.3.2",
    "@types/jest": "^26.0.23",
    "@typescript-eslint/eslint-plugin": "^4.27.0",
    "@typescript-eslint/parser": "^4.27.0",
    "@vue/compiler-sfc": "^3.1.1",
    "@vue/composition-api": "^1.0.0-rc.12",
    "@vue/test-utils": "^2.0.0-rc.8",
    "@yarnpkg/pnpify": "^3.0.0-rc.7",
    "babel-jest": "^26.6.3",
    "babel-loader": "^8.2.2",
    "better-docs": "^2.3.2",
    "copy-webpack-plugin": "^9.0.0",
    "css-loader": "^5.2.6",
    "eslint": "^7.29.0",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-jest": "^24.3.6",
    "eslint-plugin-jsdoc": "^35.4.0",
    "eslint-plugin-vue": "^7.11.1",
    "eslint-webpack-plugin": "^2.5.4",
    "html-webpack-plugin": "^5.3.1",
    "jest": "^26.6.3",
    "jest-cucumber-fusion": "^0.8.1",
    "jest-serializer-vue": "^2.0.2",
    "jsdoc": "^3.6.7",
    "pnp-webpack-plugin": "^1.6.4",
    "pug": "^3.0.2",
    "pug-bem-plain-loader": "^1.1.5",
    "sass": "^1.25.0",
    "sass-loader": "^12.1.0",
    "stylelint": "^13.13.1",
    "stylelint-config-airbnb": "0.0.0",
    "stylelint-order": "^4.1.0",
    "stylelint-scss": "^3.19.0",
    "stylelint-webpack-plugin": "^2.2.1",
    "ts-jest": "^26.5.6",
    "ts-loader": "^9.2.3",
    "typescript": "^4.3.4",
    "vue-class-component": "^8.0.0-rc.1",
    "vue-eslint-parser": "^7.6.0",
    "vue-jest": "^5.0.0-alpha.10",
    "vue-loader": "^16.3.0",
    "vue-style-loader": "^4.1.3",
    "webpack": "^5.39.1",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^3.11.2"
  }

webpack.config.js

const path = require('path');
const { VueLoaderPlugin } = require('vue-loader')
const ESLintPlugin = require('eslint-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const { rules, resolve, resolveLoader } = require('./tools/webpackCommon.js');

module.exports = (env, args) => {
  const IS_DEV = args.mode === 'development';
  const devtool = IS_DEV ? 'eval-source-map' : 'inline';
  const plugins = [
    new VueLoaderPlugin(),
    new CopyWebpackPlugin({
      patterns: [
        { from: './src/index.html' }
      ]
    }),
  ];
  if (IS_DEV) {
    plugins.concat([
      new ESLintPlugin({
        extensions: ['vue', 'ts', 'js'],
        files: ['src'],
        lintDirtyModulesOnly: true,
        failOnError: !!args.lintErrorFail,
        failOnWarning: false,
      }),
      new StyleLintPlugin({
        files: ['./src/**/*.{vue,htm,html,css,sss,less,scss,sass}'],
      })
    ]);
  }
  return {
    mode: args.mode,
    devtool,
    entry: path.resolve(__dirname, 'src/bootstrap/index.ts'),
    output: {
      filename: '[name].js',
    },
    resolve: {
      ...resolve,
      extensions: ['.vue', '.ts', '.js', '.png'],
    },
    resolveLoader,
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader',
        },
        {
          test: /\.ts?$/,
          loader: 'ts-loader',
          options: {
            appendTsSuffixTo: [/\.vue$/],
          },
          exclude: file => (
            /node_modules/.test(file) &&
            !/\.vue\.js/.test(file)
          )
        },
        {
          test: /\.(png|svg|jpg|jpeg|gif)$/i,
          type: 'asset/resource',
        },
        ...rules
      ],
    },
    plugins,
    devServer: {
      open: 'Chrome',
      overlay: true,
      hot: true,
      port: 9000,
    },
  };
};

storybook/main.js

const path = require('path');
const { rules, resolve, resolveLoader } = require('../tools/webpackCommon.js');

module.exports = {
  core: {
    builder: 'webpack5',
  },
  stories: ['./stories/**/*.stories.js'],
  addons: [
    '@storybook/addon-docs',
    '@storybook/addon-essentials',
    '@storybook/addon-links',
    '@storybook/addon-storyshots',
  ],
  webpackFinal: async (config) => {
    config.resolve = {
      ...config?.resolve ?? {},
      alias: {
        ...config?.resolve?.alias ?? {},
        ...resolve.alias,
        '@sb/utils': path.resolve(__dirname, 'utils.js'),
      },
      plugins: [
        ...config?.resolve?.plugins ?? [],
        ...resolve.plugins
      ],
    };
    config.resolveLoader = {
      ...config?.resolveLoader ?? {},
      plugins: [
        ...config?.resolveLoader?.plugins ?? [],
        ...resolveLoader.plugins,
      ],
    };
    config.module.rules.push(...rules);
    return config;
  },
};

tools/webpackCommon.js

const path = require('path');
const PnpWebpackPlugin = require(`pnp-webpack-plugin`);

module.exports = {
  resolve: {
    alias: {
      '@jwe/interfaces': path.resolve(__dirname, '../src/tools/interfaces.ts'),
      '@jwe/utils': path.resolve(__dirname, '../src/tools/utils.ts'),
      '@jwe': path.resolve(__dirname, '../src'),
    },
    plugins: [
      PnpWebpackPlugin
    ]
  },
  resolveLoader: {
    plugins: [
      PnpWebpackPlugin.moduleLoader(module),
    ],
  },
  rules: [
    {
      test: /\.pug$/,
      loader: 'pug-bem-plain-loader',
      options: {
        b: 'jwe-',
        basedir: path.resolve(__dirname, '../src/tools'),
      },  
    },
    {
      test: /\.sass$/,
      use: [
        'vue-style-loader',
        'css-loader',
        {
          loader: 'sass-loader',
          options: {
            implementation: require('sass'),
            sourceMap: true,
            sassOptions: {
              indentedSyntax: true,
              includePaths: [
                path.resolve(__dirname, '../src/tools/styles')
              ],
            },
          },
        }
      ]
    }
  ],
};

System System: OS: Windows 10 10.0.19043 CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz Binaries: Node: 14.17.1 - C:\Program Files\nodejs\node.EXE Yarn: 2.4.2 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.59)

markuslangl commented 3 years ago

Hi, I can confirm this issue with a brand-new installation of Storybook 6.4.0-beta.22 (with webpack5 builder) and yarn 3.1. Apparently this is caused by missing peer dependencies which yarn 1 accepts, but yarn 2+ not.

Steps to reproduce

I can reproduce this issue in a clean project by following these steps by creating an empty Vue 3 project with yarn workspaces:

# Create test directories
mkdir -p storybook-test/test && cd storybook-test

# Set yarn version to the latest 3.1
yarn set version berry

# Add test workspace to package.json
echo '{
  "workspaces": [
    "test"
  ],
  "packageManager": "yarn@3.1.0"
}' > package.json

# Add latest Vue.js 3 to the project
yarn add -D vue@next

# Install Storybook 6.4 with Webpack 5 builder
npx sb@next init --builder webpack5

Now, when running yarn storybook, I get the same error:

info @storybook/vue3 v6.4.0-beta.22
info
info => Loading presets
WARN   Failed to load preset: "$PWD/storybook-test/.yarn/__virtual__/@storybook-manager-webpack5-virtual-bb66779194/0/cache/@storybook-manager-webpack5-npm-6.4.0-beta.22-4f6bd96784-3a7a473554.zip/node_modules/@storybook/manager-webpack5/dist/cjs/presets/manager-preset.js"
ERR! Error: @storybook/ui tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.
ERR!
ERR! Required package: react (via "react/package.json")
ERR! Required by: @storybook/ui@virtual:58b6eb0975e34d0139019faeccbfdac2f2dee6d9d51cca86b07b711ec36ff1fedd3f11ce1ba5ee5b122d630e84a3670034e722379d6aaa1237ea656bdb5020c5#npm:6.4.0-beta.22 (via $PWD/storybook-test/.yarn/__virtual__/@storybook-ui-virtual-f42984901e/0/cache/@storybook-ui-npm-6.4.0-beta.22-c73bc3c321-f0db16d19d.zip/node_modules/@storybook/ui/)
ERR! Ancestor breaking the chain: root-workspace-0b6124@workspace:.
ERR!
ERR!
ERR! Require stack:
ERR! - $PWD/storybook-test/.yarn/__virtual__/@storybook-ui-virtual-f42984901e/0/cache/@storybook-ui-npm-6.4.0-beta.22-c73bc3c321-f0db16d19d.zip/node_modules/@storybook/ui/noop.js
ERR!     at Function.external_module_.Module._resolveFilename ($PWD/storybook-test/.pnp.cjs:28587:55)
ERR!     at resolveFileName ($PWD/storybook-test/.yarn/cache/resolve-from-npm-5.0.0-15c9db4d33-4ceeb9113e.zip/node_modules/resolve-from/index.js:29:39)
ERR!     at resolveFrom ($PWD/storybook-test/.yarn/cache/resolve-from-npm-5.0.0-15c9db4d33-4ceeb9113e.zip/node_modules/resolve-from/index.js:43:9)
ERR!     at module.exports ($PWD/storybook-test/.yarn/cache/resolve-from-npm-5.0.0-15c9db4d33-4ceeb9113e.zip/node_modules/resolve-from/index.js:46:47)
ERR!     at Object.<anonymous> ($PWD/storybook-test/.yarn/__virtual__/@storybook-ui-virtual-f42984901e/0/cache/@storybook-ui-npm-6.4.0-beta.22-c73bc3c321-f0db16d19d.zip/node_modules/@storybook/ui/paths.js:17:18)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1063:30)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:928:32)
ERR!     at Function.external_module_.Module._load ($PWD/storybook-test/.pnp.cjs:28436:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:952:19)
ERR!     at require (internal/modules/cjs/helpers.js:88:18)
ERR!     at Object.<anonymous> ($PWD/storybook-test/.yarn/__virtual__/@storybook-manager-webpack5-virtual-bb66779194/0/cache/@storybook-manager-webpack5-npm-6.4.0-beta.22-4f6bd96784-3a7a473554.zip/node_modules/@storybook/manager-webpack5/dist/cjs/presets/manager-preset.js:61:38)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1063:30)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:928:32)
ERR!     at Function.external_module_.Module._load ($PWD/storybook-test/.pnp.cjs:28436:14)
ERR!  Error: @storybook/ui tried to access react (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

<...>

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

(Please note, that I've replaced the full path to the storybook-test directory with $PWD).

Workaround

I can run yarn storybook again by following these steps:

# Install babel peer dependencies mentioned in the .babelrc
# The list of dependencies has been extracted from the file generated by
# npx sb@next babelrc
yarn add -D \
  @babel/preset-env \
  @babel/plugin-transform-shorthand-properties \
  @babel/plugin-transform-block-scoping \
  @babel/plugin-proposal-decorators \
  @babel/plugin-proposal-class-properties \
  @babel/plugin-proposal-private-methods \
  @babel/plugin-proposal-export-default-from \
  @babel/plugin-syntax-dynamic-import \
  @babel/plugin-proposal-object-rest-spread \
  @babel/plugin-transform-classes \
  @babel/plugin-transform-arrow-functions \
  @babel/plugin-transform-parameters \
  @babel/plugin-transform-destructuring \
  @babel/plugin-transform-spread \
  @babel/plugin-transform-for-of \
  babel-plugin-macros \
  @babel/plugin-proposal-optional-chaining \
  @babel/plugin-proposal-nullish-coalescing-operator \
  babel-plugin-polyfill-corejs3 \
  core-js

# Add missing peer dependencies
echo 'packageExtensions:
  "@mdx-js/loader@*":
    dependencies:
      "react": "*"
  "@mdx-js/react@*":
    dependencies:
      "react": "*"
  "@storybook/ui@*":
    dependencies:
      "react": "*"
      "react-dom": "*"
  "@storybook/builder-webpack5@*":
    dependencies:
      "react": "*"
      "react-dom": "*"
  "@storybook/manager-webpack5@*":
    dependencies:
      "react": "*"
      "react-dom": "*"' > .yarnrc.yml

# Updating yarn with changes from .yarnrc.yml
yarn

Now running yarn storybook works again, but:

info => Loading presets info => Using implicit CSS loaders info => Using default Webpack5 setup [webpack-dev-middleware] wait until bundle finished 10% building 0/1 entries 0/0 dependencies 0/0 modules(node:296950) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader (Use node --trace-deprecation ... to show where the warning was created) info => Using prebuilt manager 99% done plugins webpack-hot-middlewarewebpack built preview 97716a8da2eb98af6fec in 16354ms ╭──────────────────────────────────────────────────────╮ │ │ │ Storybook 6.4.0-beta.22 for Vue3 started │ │ 18 s for preview │ │ │ │ Local: http://localhost:6007/ │ │ On your network: http://192.168.229.137:6007/ │ │ │ ╰──────────────────────────────────────────────────────╯ (node:296950) UnhandledPromiseRejectionWarning: Error: spawn ENOTDIR at ChildProcess.spawn (internal/child_process.js:403:11) at Object.spawn (child_process.js:553:9) at module.exports ($PWD/storybook-test/.yarn/cache/open-npm-7.4.2-a378c23959-3333900ec0.zip/node_modules/open/index.js:175:34) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:296950) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4535) (node:296950) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 99% done plugins webpack-hot-middlewarewebpack built preview 9145ff9133235a7a3bda in 1510ms


(Please note that these messages also appear when Storybook is running a single time on port 6006).

## System details

* OS: Fedora 34
* Node: 14.16.1
* npm: 6.14.12
* yarn: 3.1
shilman commented 1 year ago

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if: