Storybook: Storybook failes to start when there is no node_modules folder

Created on 18 Nov 2019  路  7Comments  路  Source: storybookjs/storybook

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 :)

compatibility with other tools feature request

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_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.

All 7 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tirli picture tirli  路  3Comments

dnlsandiego picture dnlsandiego  路  3Comments

shilman picture shilman  路  3Comments

miljan-aleksic picture miljan-aleksic  路  3Comments

arunoda picture arunoda  路  3Comments