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

Storybook failes to start when there is no node_modules folder #8863

Closed
wintercounter opened this issue Nov 18, 2019 · 7 comments
Closed

Storybook failes to start when there is no node_modules folder #8863

wintercounter opened this issue Nov 18, 2019 · 7 comments

Comments

@wintercounter
Copy link

As the title says.

The issue is with this line: _path.default.join(cacheDir, 'records.json'),

cacheDir will be undefined by find-cache-path if no node_modules exist.

It's just a minor bug as usually you tend to have node_modules.

To Reproduce
Steps to reproduce the behavior:

  1. Go to your project root
  2. Make sure you have no dependencies / delete node_modules
  3. Run storybook
  4. See error

Expected behavior
Works :)

@ndelangen
Copy link
Member

Someone installs storybook...

This adds dependencies...

So the situation where the user has no dependencies and no node_modules should never happen.

Or is there some way of adding storybook without adding dependencies/node_modules?

I think the expected behaviour is the error actually.

If you run yarn install then try to run storybook, that should resolve the error, right?

@wintercounter
Copy link
Author

I'm having storybook globally installed (it actually comes from another global tool).

I found out this on a project with no dependencies because we're just displaying SVG icons in Storybook. We have one story file with require.context to all SVGs and using the mentioned global tool we generate Storybook to browse them. This project had a single dependency before, now we removed it, that's how we found out that it doesn't work. Creating an empty node_modules folder makes it work just fine.

@ndelangen
Copy link
Member

I'm open to accepting a PR to fix this, but we don't want to actively support installing storybook globally. We don't document this is possible anywhere.

I suspect that:

cacheDir will be undefined by find-cache-path if no node_modules exist.

Is just the tip of the iceberg

@JRGranell
Copy link

JRGranell commented Nov 18, 2019

We've just run into this issue as well. We have a multi-package repo using lerna which "hoists" shared packages to repo root. This means that our package may not have any specific node_modules and storybook errors with the following message and cannot start.

Broken build, fix the error below.
WARN You may need to refresh the browser.
ERR! TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
ERR!     at validateString (internal/validators.js:107:11)
ERR!     at Object.join (path.js:1037:7)
ERR!     at _default (.../node_modules/@storybook/core/dist/server/manager/manager-webpack.config.js:144:32)
ERR!     at Object.managerWebpack(.../node_modules/@storybook/core/dist/server/manager/manager-preset.js:39:38)
ERR!     at ...node_modules/@storybook/core/dist/server/presets.js:82:72

note ... denotes where I have replaced my full path

Fixed by making an empty node_modules within each package - although this is currently manual. Spent quite a while following this thread #6204, and while it may work for some, it was a red herring for us.

@ndelangen
Copy link
Member

It seems there's a PR fixing this in find-cache-path:
sindresorhus/find-cache-dir#20

@stale
Copy link

stale bot commented Dec 9, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 9, 2019
@pixelmanya
Copy link

Seems like this issue has been fixed in v3.2.0

@stale stale bot removed the inactive label Dec 13, 2019
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

4 participants