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]: Storybook couldn't evaluate your #30195

Open
ZhuravelAndreyVladimirov opened this issue Jan 6, 2025 · 8 comments · Fixed by mParticle/aquarium#529
Open

[Bug]: Storybook couldn't evaluate your #30195

ZhuravelAndreyVladimirov opened this issue Jan 6, 2025 · 8 comments · Fixed by mParticle/aquarium#529

Comments

@ZhuravelAndreyVladimirov

Describe the bug

when I try to run it gives an error:

SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook\main.ts file.

Original error:
Error: Transform failed with 1 error:
(define name):1:0: ERROR: Expected identifier but found "import"
    at failureErrorWithLog (\node_modules\esbuild\lib\main.js:1476:15)
    at responseCallbacks.<computed> (\node_modules\esbuild\lib\main.js:622:9)
    at Socket.readFromStdout (\node_modules\esbuild\lib\main.js:600:7)
    at Socket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)
    at loadMainConfig (.\node_modules\@storybook\core\dist\common\index.cjs:17511:11)
    at async buildDevStandalone (.\node_modules\@storybook\core\dist\core-server\index.cjs:37134:11)
    at async withTelemetry (.\node_modules\@storybook\core\dist\core-server\index.cjs:35757:12)
    at async dev (.\node_modules\@storybook\core\dist\cli\bin\index.cjs:2591:3)
    at async s.<anonymous> (.\node_modules\@storybook\core\dist\cli\bin\index.cjs:2643:74)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

I use next js version 14
I found answers for Vite but couldn't find one that suited me

Reproduction link

https://stackblitz.com/edit/github-p7lfsqcw?file=.storybook%2Fmain.ts,.storybook%2Fpreview.ts&preset=node

Reproduction steps

No response

System

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 AMD Ryzen 5 2600X Six-Core Processor
  Binaries:
    Node: 22.0.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD <----- active
    npm: 10.5.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.89)
  npmPackages:
    @storybook/addon-essentials: 8.4.2 => 8.4.2
    @storybook/addon-interactions: 8.4.2 => 8.4.2
    @storybook/addon-onboarding: 8.4.2 => 8.4.2
    @storybook/blocks: 8.4.2 => 8.4.2
    @storybook/nextjs: ^8.4.2 => 8.4.7
    @storybook/preview-api: ^8.4.2 => 8.4.7
    @storybook/react: 8.4.2 => 8.4.2
    @storybook/test: 8.4.2 => 8.4.2
    eslint-plugin-storybook: ^0.11.0 => 0.11.1
    storybook: 8.4.2 => 8.4.2

Additional context

No response

Copy link
Contributor

greptile-apps bot commented Jan 6, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
This error occurs because esbuild is unable to process the TypeScript imports in your .storybook/main.ts file. For Next.js 14, modify your .storybook/main.ts to use the following format:

import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
  framework: '@storybook/nextjs',
  stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-onboarding',
    '@storybook/addon-interactions',
  ],
};

export default config;

Ensure you have @storybook/nextjs installed and that your TypeScript configuration (tsconfig.json) includes the Storybook directory.

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Edit Issue Bot Settings · Greptile

@ZhuravelAndreyVladimirov
Copy link
Author

I switched to using "@storybook/nextjs": "8.4.1" and the problem was solved

@nathan-schmidt-viget
Copy link

I was running into this same problem and it has to do with esbuild. esbuild released a new version so updating the lock files should fix it.
It was originally tracked in this issue

@valentinpalkovic
Copy link
Contributor

@ZhuravelAndreyVladimirov Does updating your lock file fix the issue (updating the transitive dependency esbuild)?

@birksy89
Copy link

I have this issue after deleting my lock file and reinstalling

@matthew-gladman-oua
Copy link

I had similar issues, with the latest storybook and esbuild, also make sure you're using main.ts instead of main.tsx. That was our issue

@birksy89
Copy link

For me, I solved the problem I was having by clearing the npx cache

I was running into this issue while trying to run an upgrade command, which I spotted was using the npx cache.

I'd seen in other threads that there was an issue with ESbuild (which had been fixed by the time I was reading) but I wondered if perhaps my npx cache still had that version.

Not saying that was the exact issue, but after clearing the cache - I was able to proceed.

@sjoqvist
Copy link

I got the same error code when upgrading from Storybook 8.4.7 to 8.5.0, although maybe for a different reason:

@storybook/core v8.5.0

SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.ts file.

Original error:
SyntaxError: The requested module '@storybook/react-vite' does not provide an export named 'StorybookConfig'
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:385:37)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:363:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1569:24)
    at Module._compile (node:internal/modules/cjs/loader:1721:5)
    at Object.loadTS [as .ts] (node:internal/modules/cjs/loader:1831:10)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1495:12)
    at loadMainConfig (./node_modules/@storybook/core/dist/common/index.cjs:17550:11)
    at async buildDevStandalone (./node_modules/@storybook/core/dist/core-server/index.cjs:37127:11)
    at async withTelemetry (./node_modules/@storybook/core/dist/core-server/index.cjs:35750:12)
    at async dev (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2591:3)
    at async s.<anonymous> (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2643:74)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

My fix:

diff --git a/images/web/.storybook/main.ts b/images/web/.storybook/main.ts
index 7eb6921..44d8c39 100644
--- a/images/web/.storybook/main.ts
+++ b/images/web/.storybook/main.ts
@@ -1,4 +1,4 @@
-import { StorybookConfig } from '@storybook/react-vite';
+import type { StorybookConfig } from '@storybook/react-vite';
 import { mergeConfig } from 'vite';

 const config: StorybookConfig = {

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

Successfully merging a pull request may close this issue.

6 participants