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]: All npx storybook@latest ... commands fail with Error: Cannot find module './util' #23220

Closed
tremby opened this issue Jun 26, 2023 · 8 comments · Fixed by #23221
Closed

Comments

@tremby
Copy link

tremby commented Jun 26, 2023

Describe the bug

After getting this error when trying the npx storybook@latest init command on my NextJS project, I cleared NPM/NPX caches, and also tried on a brand new blank project, and it failed with the same message each time.

[me@myhost:~/tmp]$ npx storybook@latest init
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y
node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module './util'
Require stack:
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/common/index.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/FileSystemCache.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/index.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/core-common/dist/index.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/telemetry/dist/index.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/dist/generate.js
- /home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/bin/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/common/index.js:30:27)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/common/index.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/FileSystemCache.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/file-system-cache/lib/index.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/core-common/dist/index.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/telemetry/dist/index.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/dist/generate.js',
    '/home/me/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/bin/index.js'
  ]
}

Node.js v18.16.1

To Reproduce

npx storybook@latest init

System

> Please paste the results of npx storybook@latest info here.

I get the same error when running that.

- Linux (Ubuntu 22.04.2)
- Node v18.16.1
- NPM v9.5.1

Additional context

No response

@TooTallNate
Copy link

I've reported this to the file-system-cache dependency's issue tracker as well: philcockfield/file-system-cache#30

@tremby
Copy link
Author

tremby commented Jun 26, 2023

Temporary workaround:

  1. Try to run npx storybook@latest info or whatever command, see the error.
  2. cd to storybook's npx directory (in my example above that's cd /home/me/.npm/_npx/bc7e1e37fcb46ffc)
  3. npm i [email protected]
  4. Go back where you were and run the npx storybook command again.

@JReinhold
Copy link
Contributor

Thanks for reporting this. I'm unable to reproduce this locally, but I think that's because I'm running MacOS with the default file system which is case-insensitive, so it doesn't get hit by this issue.

We're seeing the same errors in our CI right now, eg.: https://app.circleci.com/pipelines/github/storybookjs/storybook/53541/workflows/92543e18-fb1c-4a72-b7bf-9f2431a71b9a/jobs/550427

@karlo-humanmanaged
Copy link

I worked around this in my pnpm monorepo project by having an override defined in the root package.json as:

"pnpm": {
    "overrides": {
      "file-system-cache": "2.3.0"
    }
  }

@augustobmoura
Copy link

augustobmoura commented Jun 27, 2023

Thanks for reporting this. I'm unable to reproduce this locally, but I think that's because I'm running MacOS with the default file system which is case-insensitive, so it doesn't get hit by this issue.

For reproducing linux issues, you can quickly reproduce it by using docker, try:

docker run -it --rm node:16 npx -y [email protected] --version

It is definitely failing for me

@yannbf
Copy link
Member

yannbf commented Jun 27, 2023

Hey everyone! We're working on a fix and will be making a release shortly, you can follow the open PR for 7.0.24 or you can currently work around it via overrides in your package.json files, e.g.:

pnpm

"pnpm": {
    "overrides": {
      "file-system-cache": "2.3.0"
    }
  }

npm

  "overrides": {
      "file-system-cache": "2.3.0"
  }

yarn

  "resolutions": {
      "file-system-cache": "2.3.0"
  }

And as soon as the new version of Storybook is released, you can remove it and upgrade.

@yannbf yannbf reopened this Jun 27, 2023
@yannbf
Copy link
Member

yannbf commented Jun 27, 2023

Hey everyone! We have released Storybook 7.0.24 containing a fix to this issue. Please upgrade and let us know if you have any issues! Thanks for your patience :))

@seriouz
Copy link
Contributor

seriouz commented Jun 30, 2023

@yannbf The author of file-system-cache fixed the library, we can now use the new version 2.4.1.
Here is a MR with the version: #23253

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

Successfully merging a pull request may close this issue.

7 participants