storybookjs / storybook

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

[Bug]: Cannot find module 'jsonfile/utils' #22682

Open Fydon opened 1 year ago

Fydon commented 1 year ago

Describe the bug

I tried to update using npx storybook@latest upgrade but it failed with the following

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

Error: Cannot find module 'jsonfile/utils'
Require stack:
- my-project\node_modules\@storybook\core-server\node_modules\fs-extra\lib\json\output-json.js
- my-project\node_modules\@storybook\core-server\node_modules\fs-extra\lib\json\index.js
- my-project\node_modules\@storybook\core-server\node_modules\fs-extra\lib\index.js
- my-project\node_modules\@storybook\core-server\dist\index.js
- my-project\node_modules\@storybook\cli\dist\generate.js
- my-project\node_modules\@storybook\cli\bin\index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (my-project\node_modules\@storybook\core-server\node_modules\fs-extra\lib\json\output-json.js:3:23)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'my-project\\node_modules\\@storybook\\core-server\\node_modules\\fs-extra\\lib\\json\\output-json.js',
    'my-project\\node_modules\\@storybook\\core-server\\node_modules\\fs-extra\\lib\\json\\index.js',
    'my-project\\node_modules\\@storybook\\core-server\\node_modules\\fs-extra\\lib\\index.js',
    'my-project\\node_modules\\@storybook\\core-server\\dist\\index.js',
    'my-project\\node_modules\\@storybook\\cli\\dist\\generate.js',
    'my-project\\node_modules\\@storybook\\cli\\bin\\index.js'
  ]
}

To Reproduce

Run npx storybook@latest upgrade on a project that doesn't already include jsonfile. Looking at the Angular project on storybook.new, the package-json.lock already includes jsonfile due to multiple dependencies including it as a dependency, e.g. node_modules/@compodoc/ngd-transformer/node_modules/fs-extra so I'm not sure if I can reproduce it there.

System

Environment Info:

  System:
    OS: Windows 10 10.0.22621
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.42)
  npmPackages:
    @storybook/addon-actions: ~7.0.12 => 7.0.12
    @storybook/addon-essentials: ~7.0.12 => 7.0.12
    @storybook/addon-links: ~7.0.12 => 7.0.12
    @storybook/angular: ~7.0.12 => 7.0.12

Additional context

Running npm install --save-dev jsonfile/utils resolved the error. The above info was generated after I successfully updated from 7.0.0-beta.34.

lamualfa commented 1 year ago

Just delete the package-lock.json and run the npm install again.