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

Can't start project with windows backslash paths as configPath #18226

Closed
Matt-Tranzact opened this issue May 14, 2022 · 4 comments
Closed

Can't start project with windows backslash paths as configPath #18226

Matt-Tranzact opened this issue May 14, 2022 · 4 comments

Comments

@Matt-Tranzact
Copy link

Describe the bug
Backslashes () are used by windows for paths instead of forward slashes (/) used in linux/mac

To Reproduce

  1. Install storybook in a react project in OS Window
  2. run npm run storybook
  3. You'll get following error:
ERR! Error: No configuration files have been found in your configDir (C:\...\react-components16\.storybook).
ERR! Storybook needs either a "main" or "config" file.

image

System

    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.10.0 - ~\Proyectos\sapo\react-components16\node_modules\.bin\npm.CMD
  Browsers:
    Chrome: 101.0.4951.54
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.39)
  npmPackages:
    @storybook/addon-actions: 6.4.22 => 6.4.22
    @storybook/addon-essentials: 6.4.22 => 6.4.22
    @storybook/addon-links: 6.4.22 => 6.4.22
    @storybook/builder-webpack5: ^6.4.22 => 6.4.22
    @storybook/manager-webpack5: ^6.4.22 => 6.4.22
    @storybook/react: 6.4.22 => 6.4.22
    @storybook/storybook-deployer: ^2.8.11 => 2.8.11```  

Additional context
I'm currently migrating storybook to version 6.4.22, but after migration is finished I got the error described above. At first, I thought It was related to Webpack v5 using react-scripts 5, but after some digging I found out there is a problem related to npm lib glob which @storybook-core-common lib uses in validateConfigurationFiles function:

function validateConfigurationFiles(configDir) {
  var extensionsPattern = `{${Array.from(_interpretFiles.boost).join(',')}}`;

  /**  In Windows this returns 'C:\Users\daniel.hernandez\Proyectos\sapo\react-components16\.storybook\main.js'
  * And with this path _glob.default.sync() always returns an empty array
  **/
  const pathSelected = _path.default.resolve(configDir, `main.js`)
  console.log(pathSelected)
  console.log(_glob.default.sync(pathSelected))
    
  /** Using this fix it returns 'C:/Users/daniel.hernandez/Proyectos/sapo/react-components16/.storybook/main.js'
  * And with this path _glob.default.sync() returns the correct minimatch data in array which lets length != to 0 making exist function 
  * below to return true and allowing user to run storybook successfully.
  **/
  const forwardSlashPath = _path.default.resolve(configDir, `main.js`).replaceAll('\\','/')
  console.log(forwardSlashPath)
  console.log(_glob.default.sync(forwardSlashPath))

  var exists = function (file) {
    return !!_glob.default.sync(_path.default.resolve(configDir, `${file}${extensionsPattern}`)).length;
  };

  var main = exists('main');
  var config = exists('config');
  ...
  }

It seems it is related to this issue from glob lib: isaacs/node-glob#468 but idk if there are going to fix it any time soon.
That's why a patch could also be added in storybook to fix this bug which doesn't let windows users like me to start storybook

@nicolas377
Copy link

This has nothing to do with isaacs/node-glob#468, that's a feature targeting v8. This project uses v7, which means that this is affected by isaacs/node-glob#471. It will be fixed by the upstream PR tied to that issue. Hopefully, the v7 branch will have the fix by today.

@isaacs
Copy link

isaacs commented May 15, 2022

Should be fixed by glob@7.2.3. If it isn't, please post a new issue at https://github.com/isaacs/node-glob/issues, ideally with a reproduction case. Thanks!

@mhoritani
Copy link

This issue popped up for us when we updated storybook from 6.4.22 to 6.5.6.

@shilman
Copy link
Member

shilman commented Jun 9, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants