test-runner icon indicating copy to clipboard operation
test-runner copied to clipboard

[question] Error: Cannot find module 'detect-package-manager'

Open y-temp4 opened this issue 1 year ago • 1 comments

It seems that when running tests for a Storybook managed in a separate package, with a package.json that only includes @storybook/test-runner, concurrently, and wait-on as dependencies, an error occurs stating Error: Cannot find module 'detect-package-manager'.

I suspect this error is due to detect-package-manager being included in the devDependencies of @storybook/test-runner, rather than in its dependencies.

The version of @storybook/test-runner being used is 0.16.0.

y-temp4 avatar Dec 06 '23 06:12 y-temp4

I see the same thing with semver when using pnpx with hoisting turned off in .npmrc. Injecting a dep on semver then gives the detect-package-manager error described here. After injecting a dep on that too, it works.

So, in other words, this package is depending on npm's (and yarn 1's) default behavior of hoisting dependencies and needs either a deprendency or peerDependency on both semver and detect-package-manager.

I haven't tested, but with newer versions of yarn that have PnP enabled it probably fails similarly.

anomiex avatar Feb 20 '24 18:02 anomiex

Hey everyone! In the most recent versions of the test-runner (0.18.0), neither semver nor detect-package-manager are used anymore, so this problem should go away. Please upgrade whenever you can! Thanks <3

yannbf avatar May 16 '24 13:05 yannbf