storybookjs / storybook

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

Can no longer install Storybook with pnpm (invalid peer dependency) #16705

Closed kaiyoma closed 1 year ago

kaiyoma commented 2 years ago

Describe the bug Storybook no longer installs with pnpm due to an invalid peer dependency deep within the tree.

To Reproduce Try to install 6.3.12 of @storybook/addon-docs with pnpm and you get this error:

 ERR_PNPM_INVALID_PEER_DEPENDENCY  ..\..\packages\cv-components > @storybook/addon-docs > @storybook/builder-webpack4 > terser-webpack-plugin: terser@5.10.0 requires a peer of acorn@^8.5.0 but version 7.4.1 was installed.

System

Environment Info:

  System:
    OS: Windows 10 10.0.19043
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 14.18.1 - C:\Program Files\nodejs\node.EXE
    npm: 7.24.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 95.0.4638.69
    Edge: Spartan (44.19041.1266.0), Chromium (95.0.1020.53)

Additional context You can see the problem in the package.json here: https://github.com/storybookjs/storybook/blob/v6.3.12/addons/docs/package.json

The version of acorn is not valid.

kaiyoma commented 2 years ago

For anyone else hitting this, here's a .pnpmfile.cjs workaround:


function readPackage(packageJson, context) {
  // Workaround for https://github.com/storybookjs/storybook/issues/16705
  if (packageJson.name === "@storybook/addon-docs") {
    context.log("Fixing the acorn dependency for @storybook/addon-docs");
    packageJson.dependencies.acorn = "^8.5.0";
  }

  return packageJson;
}
IanVS commented 1 year ago

pnpm support is vastly improved in Storybook 7.0. Can you give it a try with pnpx sb@next upgrade --prerelease and let us know if you're still having problems?