Description
Describe the bug
Thanks in advance for your help with this matter!
I installed Storybook in an empty directory with npx storybook@latest init
. Storybook detected the empty directory, and I selected "React + Vite (TS)." All dependencies were installed without issue, but when Storybook started up, it crashed with the following error message:
=> Failed to build the preview
Error: Failed to resolve entry for package "isobject". The package may have incorrect main/module/exports specified in its package.json.
at packageEntryFailure (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:16545:15)
at resolvePackageEntry (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:16542:3)
at tryNodeResolve (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:16407:18)
at ResolveIdContext.resolveId (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:16180:19)
at EnvironmentPluginContainer.resolveId (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:47520:17)
at async resolve (file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:48110:12)
at async file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:48128:22
at async file:///C:/Users/Owner/Desktop/code-editor/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:54155:16
at async .\node_modules@storybook\builder-vite\dist\index.js:75:4684
at async Promise.all (index 63)
I also tried initializing a Storybook project in a directory in which I had already installed React, with the same result. Running npm run storybook
also produces the same result. The Vite dev server works as expected.
Separately, I also tried Storybook with Next.js and that worked fine.
Reproduction link
https://github.com/dvorakjt/code-editor
Reproduction steps
I tried running the above repository on StackBlitz, but the error doesn't occur there. I suspect it's either specific to Windows, or somehow even more specific to my local environment. Thank you for your assistance with this matter.
System
Running npx storybook@latest info produces the following error:
C:\Users\Owner\AppData\Local\npm-cache\_npx\a181334d43285dc7\node_modules\@storybook\cli\bin\index.cjs:23
throw error;
^
Error: Cannot find module 'C:\Users\Owner\AppData\Local\npm-cache\_npx\a181334d43285dc7\node_modules\source-map\source-map.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:492:19)
at Function._findPath (node:internal/modules/cjs/loader:790:18)
at Function._resolveFilename (node:internal/modules/cjs/loader:1230:27)
at Function._load (node:internal/modules/cjs/loader:1070:27)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1335:12)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (C:\Users\Owner\AppData\Local\npm-cache\_npx\a181334d43285dc7\node_modules\@storybook\cli\node_modules\recast\lib\util.js:8:44)
at Module._compile (node:internal/modules/cjs/loader:1562:14) {
code: 'MODULE_NOT_FOUND',
path: '\\\\?\\C:\\Users\\Owner\\AppData\\Local\\npm-cache\\_npx\\a181334d43285dc7\\node_modules\\source-map\\package.json',
requestPath: 'source-map'
}
Node.js v22.13.1
Oddly, running npx storybook@8.5.2 does not trigger such an error, and I get:
$ npx storybook@8.5.2 info
Storybook Environment Info:
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Binaries:
Node: 22.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD <----- active
Browsers:
Chrome: 132.0.6834.160
Edge: Chromium (127.0.2651.74)
npmPackages:
@storybook/addon-essentials: ^8.5.3 => 8.5.3
@storybook/addon-interactions: ^8.5.3 => 8.5.3
@storybook/addon-onboarding: ^8.5.3 => 8.5.3
@storybook/blocks: ^8.5.3 => 8.5.3
@storybook/react: ^8.5.3 => 8.5.3
@storybook/react-vite: ^8.5.3 => 8.5.3
@storybook/test: ^8.5.3 => 8.5.3
eslint-plugin-storybook: ^0.11.2 => 0.11.2
storybook: ^8.5.3 => 8.5.3
Additional context
No response