Skip to content

[Bug]: SyntaxError: Cannot use import statement outside a module #23972

Closed

Description

Describe the bug

I'm using Storybook in pnpm monorepo and getting a bunch of these errors in console. Tried to upgrade to latest version but it didn't solve the problem.

@storybook/cli v7.3.2

WARN   Failed to load preset: "/Users/eden_lane/Projects/.../node_modules/.pnpm/@storybook+react-vite@7.3.2_react-dom@17.0.2_react@17.0.2_typescript@4.9.5_vite@4.4.9/node_modules/@storybook/react-vite/preset"
ERR! /Users/eden_lane/Projects/.../shared/node_modules/lazy-universal-dotenv/lib/index.mjs:1
ERR! import fs from 'fs';
ERR! ^^^^^^
ERR! 
ERR! SyntaxError: Cannot use import statement outside a module
ERR!     at internalCompileFunction (node:internal/vm:73:18)
ERR!     at wrapSafe (node:internal/modules/cjs/loader:1176:20)
ERR!     at Module._compile (node:internal/modules/cjs/loader:1218:27)
ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
ERR!     at Object.newLoader [as .mjs] (/Users/eden_lane/Projects/.../node_modules/.pnpm/esbuild-register@3.4.2_esbuild@0.18.20/node_modules/esbuild-register/dist/node.js:2262:9)
ERR!     at Module.load (node:internal/modules/cjs/loader:1117:32)
ERR!     at Module._load (node:internal/modules/cjs/loader:958:12)
ERR!     at Module.require (node:internal/modules/cjs/loader:1141:19)
ERR!     at require (node:internal/modules/cjs/helpers:110:18)
ERR!     at Object.<anonymous> (/Users/eden_lane/Projects/.../shared/node_modules/@storybook/core-common/dist/index.js:15:4029)

To Reproduce

No response

System

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M2
  Binaries:
    Node: 18.15.0 - /usr/local/bin/node
    npm: 9.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 116.0.5845.110
    Safari: 16.3
  npmPackages:
    @storybook/addon-essentials: ^7.3.2 => 7.3.2 
    @storybook/addon-interactions: ^7.3.2 => 7.3.2 
    @storybook/addon-links: ^7.3.2 => 7.3.2 
    @storybook/addon-mdx-gfm: ^7.3.2 => 7.3.2 
    @storybook/addon-onboarding: ^1.0.8 => 1.0.8 
    @storybook/blocks: ^7.3.2 => 7.3.2 
    @storybook/react: ^7.3.2 => 7.3.2 
    @storybook/react-vite: ^7.3.2 => 7.3.2 
    @storybook/react-webpack5: ^7.3.2 => 7.3.2 
    @storybook/testing-library: ^0.2.0 => 0.2.0 
  npmGlobalPackages:
    @storybook/cli: 4.0.0-alpha.0

Additional context

No response

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

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions