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:
Expected behavior
Works :)
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?
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.
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
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 https://github.com/storybookjs/storybook/issues/6204, and while it may work for some, it was a red herring for us.
It seems there's a PR fixing this in find-cache-path:
https://github.com/avajs/find-cache-dir/pull/20
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!
Seems like this issue has been fixed in v3.2.0
Most helpful comment
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_modulesand storybook errors with the following message and cannot start.Fixed by making an empty
node_moduleswithin each package - although this is currently manual. Spent quite a while following this thread https://github.com/storybookjs/storybook/issues/6204, and while it may work for some, it was a red herring for us.