Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Storybook injecting packageManager pnpm 8.1.0 when you run npm run storybook #29146

Closed
stevensacks opened this issue Sep 18, 2024 · 9 comments · Fixed by #29152 or #29627
Closed
Assignees

Comments

@stevensacks
Copy link
Contributor

Describe the bug

When you run npm run storybook on a vite project, it is injecting this into the package.json every single time:

"packageManager": "pnpm@8.1.0+sha1.09ebf306075e96037432071992bb00340c263d85"
  1. This breaks the Chromatic Github Action.
  2. If I want to use pnpm, I will. Don't force it on me.
  3. Version 8.1.0 is bugged with Node 20. You have to use 8.3.1 minimum or pnpm can't install libraries.

Reproduction link

https://storybook.js.org/

Reproduction steps

As stated in the description. Make a vite project and npm run storybook and it will inject that line into package.json every time.

Delete the line from package.json, npm run storybook, and it's back again.

System

Storybook Environment Info:

  System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.3 - ~/.nvm/versions/node/v20.17.0/bin/npm <----- active
    pnpm: 8.1.0 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
  Browsers:
    Chrome: 128.0.6613.139
    Safari: 17.6
  npmPackages:
    @storybook/addon-essentials: 8.3.1 => 8.3.1 
    @storybook/addon-interactions: 8.3.1 => 8.3.1 
    @storybook/addon-links: 8.3.1 => 8.3.1 
    @storybook/blocks: 8.3.1 => 8.3.1 
    @storybook/manager-api: 8.3.1 => 8.3.1 
    @storybook/preview-api: 8.3.1 => 8.3.1 
    @storybook/react: 8.3.1 => 8.3.1 
    @storybook/react-vite: 8.3.1 => 8.3.1 
    @storybook/test: 8.3.1 => 8.3.1 
    @storybook/theming: 8.3.1 => 8.3.1 
    @storybook/types: 8.3.1 => 8.3.1 
    chromatic: 11.10.2 => 11.10.2 
    eslint-plugin-storybook: 0.8.0 => 0.8.0 
    storybook: 8.3.1 => 8.3.1 
    storybook-dark-mode: 4.0.2 => 4.0.2 
    storybook-react-i18next: 3.1.7 => 3.1.7

Additional context

No response

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Sep 19, 2024

Thank you for reporting this bug!

If I want to use pnpm, I will. Don't force it on me.

As you might guess, we do not intend to force anyone to use a specific package manager. This is clearly a bug.

This bug occurs as soon as you have corepack enabled. We run pnpm --version in a try/catch block to determine whether the user has pnpm installed. It seems that corepack will automatically add a packageManager field as soon as it is unavailable or update it if it is outdated.

Working on a fix right now..

@eatyourgreens
Copy link

Hi! I've been running into this issue recently with a vite project, even though it was fixed in Storybook 8.3.2. Our project is using vite 5.4.8, Node 20, Storybook 8.3.5.

Running storybook dev will add either pnpm or yarn to my package.json` file.

@Profesor08
Copy link

Profesor08 commented Nov 15, 2024

Same issue with storybook@8.4.4, vite@5.4.11.

@angrybacon
Copy link

angrybacon commented Nov 15, 2024

Same issue with pnpm installed globally and Node from NVM

  • pnpm 9.13.2
  • node 20.12.2
  • storybook 8.4.4
+  "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"

@Profesor08
Copy link

Current "workaround" to solve this anoing thing is to uninstall pnpm and corepack manually. I don't use them, so I don't need them. Downgrade of srtorybook was not helpfull.

@angrybacon
Copy link

In the meantime I'm using:

COREPACK_ENABLE_AUTO_PIN=0

@stevensacks
Copy link
Contributor Author

This issue reappeared in 8.3.2

@hyrious
Copy link

hyrious commented Nov 19, 2024

@yannbf I would suggest using the which package to test pnpm existence instead of adding a new corepack env which seems only a workaround.

On the other hand, it seems too careful to choose the package manager as most of them do not compatible with each other. It should be fine to only test the lockfile and "let it crash" when people do not have correct package manager to run the project.

@eatyourgreens
Copy link

After upgrading to 8.4.7 and running npm run storybook, the contents of my package.json were deleted and replaced with:

{
  "packageManager": "pnpm@9.1.0+sha1.217063ce3fcbf44f3051666f38b810f1ddefee4a"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment