storybookjs / storybook

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

[Bug]: "NONE" Variable Not Interpreted as "no-open" flag and Lack of Warning/Error for Invalid Browser Variable #24191

Open clemencefrz opened 12 months ago

clemencefrz commented 12 months ago

Describe the bug

When running the Storybook development script, I encounter an ENOENT error with the message "NONE." This error occurs because my environment variable BROWSER is set to "NONE." However, there is no warning or error thrown if the value of process.env.BROWSER is invalid.

To Reproduce

run BROWSER="NONE" npx storybook dev

System

Environment Info:

  System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
  Browsers:
    Chrome: 110.0.5481.100
  npmPackages:
    @storybook/addon-essentials: ^7.2.3 => 7.3.0
    @storybook/addon-interactions: ^7.2.3 => 7.3.0
    @storybook/addon-links: ^7.2.3 => 7.3.0
    @storybook/addon-styling: ^1.3.6 => 1.3.7
    @storybook/blocks: ^7.2.3 => 7.3.0
    @storybook/builder-vite: ^7.2.3 => 7.3.0
    @storybook/react-vite: ^7.3.0 => 7.3.0
    @storybook/testing-library: ~0.2.0 => 0.2.0

Additional context

`node:events:491 throw er; // Unhandled 'error' event ^

Error: spawn NONE ENOENT at node_internal_captureLargerStackTrace (node:internal/errors:490:5) at node_internal_errnoException (node:internal/errors:620:12) at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Emitted 'error' event on ChildProcess instance at: at ChildProcess._handle.onexit (node:internal/child_process:289:12) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn NONE', path: 'NONE', spawnargs: [ 'http://localhost:45713/' ] }`

mwaeckerlin commented 11 months ago

Same with BROWSER=none (lowercase):

  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn none',
  path: 'none',
  spawnargs: [ 'http://localhost:6006/' ]

How to prevent storybook from opening a browser?!?

mwaeckerlin commented 11 months ago

My current workaround:

BROWSER=true npm run storybook

It then runs /bin/true instead of a browser, which just returns success…

pdr0 commented 9 months ago

I can confirm @mwaeckerlin suggestion's works