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]: Cannot find module 'storybook/internal/common' #505

Closed
eavam opened this issue Aug 16, 2024 · 10 comments · Fixed by #512
Closed

[Bug]: Cannot find module 'storybook/internal/common' #505

eavam opened this issue Aug 16, 2024 · 10 comments · Fixed by #512
Labels
bug Something isn't working needs triage

Comments

@eavam
Copy link

eavam commented Aug 16, 2024

Describe the bug

Running yarn test-storybook responds with an error Cannot find module 'storybook/internal/common'.
On version 0.16 everything is fine. With 0.17 the problems start.

To Reproduce

node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module 'storybook/internal/common'
Require stack:
- <-- PATH -->/node_modules/@storybook/test-runner/node_modules/@storybook/core-common/shim.js
- <-- PATH -->/node_modules/@storybook/test-runner/dist/test-storybook.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (<-- PATH -->/node_modules/@storybook/test-runner/node_modules/@storybook/core-common/shim.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '<-- PATH -->/node_modules/@storybook/test-runner/node_modules/@storybook/core-common/shim.js',
    '<-- PATH -->/node_modules/@storybook/test-runner/dist/test-storybook.js'
  ]
}

System

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 4.1.1 - ~/.nvm/versions/node/v20.10.0/bin/yarn <----- active
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
  Browsers:
    Chrome: 127.0.6533.120
    Safari: 17.5
  npmPackages:
    @storybook/addon-essentials: 8.1.1 => 8.1.1 
    @storybook/addon-interactions: 8.1.1 => 8.1.1 
    @storybook/addon-links: 8.1.1 => 8.1.1 
    @storybook/blocks: 8.1.1 => 8.1.1 
    @storybook/preview-api: 8.1.1 => 8.1.1 
    @storybook/react: 8.1.1 => 8.1.1 
    @storybook/react-vite: 8.1.1 => 8.1.1 
    @storybook/test: 8.1.1 => 8.1.1 
    @storybook/test-runner: 0.17.0 => 0.17.0 
    eslint-plugin-storybook: 0.8.0 => 0.8.0 
    msw-storybook-addon: 2.0.3 => 2.0.3 
    storybook: 8.1.1 => 8.1.1 
    storybook-addon-mock: 5.0.0 => 5.0.0

Additional context

No response

@eavam eavam added bug Something isn't working needs triage labels Aug 16, 2024
@kumarbha
Copy link

I am also facing the same issue. Pls help

@bklatka
Copy link

bklatka commented Aug 21, 2024

Facing same issue as above

@dudiharush
Copy link

Me too...

@dudiharush
Copy link

This bug seems to be resolved after running: npx [email protected] upgrade @eavam @kumarbha

@SoaresMG
Copy link

Same here, but I'm using [email protected] with @storybook/[email protected] (I have also tried 0.19.1).

I did upgrade other deps that's when the issue started happening, I'm trying to find which one caused it

@ericsoderberghp
Copy link

FYI, I've found that if I remove @storybook/addon-designs then the error goes away and I am able to run.

@SoaresMG
Copy link

Same here, but I'm using [email protected] with @storybook/[email protected] (I have also tried 0.19.1).

I did upgrade other deps that's when the issue started happening, I'm trying to find which one caused it

It seems that my issue was related with being in storybook@7 using [email protected] which had storybook@8 deps.

I switched to 0.16.0 and it started working again.

It was working before with storybook@7 due to the magic hand of the lock file god, that allowed some [email protected] deps to be mixed with storybook@7 itself (if I'm not mistaken it was some deps like @storybook/channels and @storybook/types and 1-2 more).

@sunilrathore24
Copy link

sunilrathore24 commented Sep 6, 2024

Same here -
it used to work earlier but probably because of some minor version upgrades, it fails with the below error.
@yannbf can you look into it?
image

  "devDependencies": {
    "@angular-devkit/build-angular": "18.0.2",
    "@angular-devkit/core": "18.0.2",
    "@angular-devkit/schematics": "18.0.2",
    "@angular-eslint/eslint-plugin": "18.0.1",
    "@angular-eslint/eslint-plugin-template": "18.0.1",
    "@angular-eslint/template-parser": "18.0.1",
    "@angular/cli": "~18.0.0",
    "@angular/compiler-cli": "18.0.1",
    "@angular/language-service": "18.0.1",
    "@babel/core": "^7.24.7",
    "@babel/plugin-proposal-decorators": "^7.24.7",
    "@babel/preset-env": "^7.24.7",
    "@babel/preset-typescript": "^7.24.7",
    "@commitlint/cli": "^17.0.2",
    "@commitlint/config-conventional": "^17.0.2",
    "@commitlint/prompt-cli": "^17.0.0",
    "@custom-elements-manifest/analyzer": "~0.5.7",
    "@mjhenkes/postcss-rtl": "^2.0.0",
    "@nx/cypress": "19.3.2",
    "@nx/eslint": "19.3.2",
    "@nx/eslint-plugin": "19.3.2",
    "@nx/js": "19.3.2",
    "@nx/storybook": "19.3.2",
    "@nx/workspace": "19.3.2",
    "@open-wc/testing": "^3.1.6",
    "@rollup/plugin-alias": "^5.1.0",
    "@rollup/plugin-node-resolve": "^15.2.3",
    "@rollup/plugin-terser": "^0.4.4",
    "@rollup/plugin-typescript": "^11.1.6",
    "@rollup/plugin-virtual": "^3.0.2",
    "@schematics/angular": "18.0.2",
    "@storybook/addon-a11y": "^8.1.7",
    "@storybook/addon-essentials": "^8.1.7",
    "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
    "@storybook/angular": "^8.1.7",
    "@storybook/blocks": "^8.1.7",
    "@storybook/components": "^8.1.7",
    "@storybook/core-events": "^8.1.7",
    "@storybook/core-server": "^8.1.7",
    "@storybook/manager-api": "^8.1.7",
    "@storybook/preview-api": "^8.1.7",
    "@storybook/test-runner": "^0.19.1",
    "@storybook/theming": "^8.1.7",
    "@storybook/types": "^8.1.7",
    "@storybook/web-components": "^8.1.7",
    "@storybook/web-components-webpack5": "^8.1.7" }

@ekeijl
Copy link

ekeijl commented Oct 10, 2024

Running into the same issue when using Yarn PnP:

> yarn run storybook-test

/<REDACTED>/.pnp.cjs:67456
      Error.captureStackTrace(firstError);
            ^

Error: @storybook/core-common tried to access storybook (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Required package: storybook (via "storybook/internal/common")
Required by: @storybook/core-common@virtual:fa7a63bce88eef2cb8a3f1c5ece91110f0f08289f1e8517bf01d3d69cbeef0a9a7bfcaa746c2f0e178177003417e002337645312a23a1888f0c1e9c5fa39c856#npm:8.2.9 (via /<REDACTED>/.yarn/__virtual__/@storybook-core-common-virtual-14814bf21c/0/cache/@storybook-core-common-npm-8.2.9-cf49c5e44e-0d70bd588a.zip/node_modules/@storybook/core-common/)

Ancestor breaking the chain: @storybook/test-runner@npm:0.19.1

It seems the @storybook/test-runner package is missing a peerDependency on the storybook package?

As a workaround, this can be patched with Yarn in your .yarnrc.yml (docs):

packageExtensions:
   '@storybook/test-runner@*':
      peerDependencies:
         storybook: ">=8"

Make sure to install the storybook package as a devDependency in your project.

@yannbf
Copy link
Member

yannbf commented Nov 4, 2024

Hey everyone! Thanks for reporting this.

Here is a quick summary:

  • This issue is the result of a structural change that was done in Storybook 8.2, which affects the way packages are requested from other dependencies.
  • This issue only happens if you are using Storybook 8 dependencies, could be coming from an addon like @storybook/addon-designs for instance.
  • If you are using Storybook 7, you must stay at version 0.16.0 of the test-runner, as stated in this table.
  • I have a PR that updates the test-runner itself to follow the new structure of packages from Storybook, which should resolve this issue. This should be fixed in the next minor release of the test-runner.

leosvelperez pushed a commit to nrwl/nx that referenced this issue Nov 18, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
I got this error locally, I think it is because @storybook/test-runner
is incompatible with storybook version
storybookjs/test-runner#505
<img width="1147" alt="Screenshot 2024-11-15 at 12 22 13 PM"
src="https://github.com/user-attachments/assets/e2a9f4c9-e784-4946-8677-b60b62ff36ef">

from https://github.com/storybookjs/test-runner#storybook-compatibility
storybook ^8.2.0 should use @storybook/test-runner ^0.19.0

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants