storybook: TypeError: Cannot read property 'lightest' of undefined
I have installed Storybook Docs as per the documentation here: https://github.com/storybookjs/storybook/blob/next/addons/docs/README.md#installation
And I have used the Manual preset configuration.
When I view the Docs tab for any of my stories I get the following error:
TypeError: Cannot read property 'lightest' of undefined
at getScrollAreaStyles (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:11822:78)
at http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:41276:100
at updateContextConsumer (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:92999:19)
at beginWork (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:93187:14)
at performUnitOfWork (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:96827:12)
at workLoop (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:96867:24)
at renderRoot (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:96950:7)
at performWorkOnRoot (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:97857:7)
at performWork (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:97769:7)
at performSyncWork (http://localhost:6006/vendors~main.e02af6e0f1f31fb510a2.bundle.js:97743:3)
Any ideas what the problem could be or where I could start looking to see the issue?
The packages used are as follows:
"@babel/core": "^7.4.5",
"@storybook/addon-docs": "^5.2.0-beta.46",
"@storybook/addon-knobs": "^5.2.0-beta.46",
"@storybook/addon-notes": "^5.2.0-beta.46",
"@storybook/html": "^5.2.0-beta.46",
"babel-loader": "^8.0.6",
"webpack": "^4.39.3"
The config.js file is as follows:
import { addParameters, configure } from '@storybook/html';
import { themes } from '@storybook/theming';
import yourTheme from './yourTheme';
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /\.stories\.(js|mdx)$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
// Option defaults:
addParameters({
docs: {
container: DocsContainer,
page: DocsPage
},
options: {
/**
* show story component as full screen
* @type {Boolean}
*/
isFullscreen: false,
/**
* display panel that shows a list of stories
* @type {Boolean}
*/
showNav: true,
/**
* display panel that shows addon configurations
* @type {Boolean}
*/
showPanel: true,
/**
* where to show the addon panel
* @type {('bottom'|'right')}
*/
panelPosition: 'bottom',
/**
* sorts stories
* @type {Boolean}
*/
sortStoriesByKind: false,
/**
* regex for finding the hierarchy separator
* @example:
* null - turn off hierarchy
* /\// - split by `/`
* /\./ - split by `.`
* /\/|\./ - split by `/` or `.`
* @type {Regex}
*/
hierarchySeparator: /\/|\./,
/**
* regex for finding the hierarchy root separator
* @example:
* null - turn off multiple hierarchy roots
* /\|/ - split by `|`
* @type {Regex}
*/
hierarchyRootSeparator: /\|/,
/**
* sidebar tree animations
* @type {Boolean}
*/
sidebarAnimations: true,
/**
* enable/disable shortcuts
* @type {Boolean}
*/
enableShortcuts: false,
/**
* show/hide tool bar
* @type {Boolean}
*/
isToolshown: true,
/**
* theme storybook, see link below
*/
theme: themes.light
}
});
// must come last
configure(loadStories, module);
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 53 (12 by maintainers)
Commits related to this issue
- feat(deps): regenerate yarn.lock file Storybook would throw an error caused by a dependency mismatch. https://github.com/storybookjs/storybook/issues/7914 — committed to sumup-oss/circuit-ui by connor-baer 5 years ago
- feat(deps): regenerate yarn.lock file Storybook would throw an error caused by a dependency mismatch. https://github.com/storybookjs/storybook/issues/7914 — committed to sumup-oss/circuit-ui by connor-baer 5 years ago
- feat(deps): regenerate yarn.lock file Storybook would throw an error caused by a dependency mismatch. https://github.com/storybookjs/storybook/issues/7914 — committed to sumup-oss/circuit-ui by connor-baer 5 years ago
@seanmhanson what happens when you run
yarn list @storybook/theming(or whatever the npm equivalent is) oryarn list @emotion/core. i suspect that thereβs some package that should be a singleton, thatβs actually installed multiple times in your project due to some yarn/npm weirdness.If you find that there are multiple copies installed, try installing
@storybook/theming, clearing your lockfile, and re-generating.Just a hunchβ¦
This same issue had occurred for us yesterday after updating our
yarn.lock(without updating storybook). Removingyarn.lock,node_modulesdid not helped.I found out, that for some reason we had two
@emotion/coreinyarn.lock. We use emotionJS in our project aswell, the version in ourpackage.jsonwas10.0.27. (I remember I already had to bump the version once to .27 when moving to SB 5.3). Bumping the version of@emotion/corein ourpackage.jsonto10.0.28helped to have just one@emotion/coreinyarn.lock.Posting this here, because maybe it will help someone.
Just in case anyone is having the same issues as mentioned above or getting this error
Cannot read property 'theme.color' of undefinedafter a recent upgrade to storybook6.1.10usingnpx sb upgradeI can confirm that a complete nuke of storybook and a fresh re-install using
npx sb initdid it for me. I think some old dependencies were hanging around and causing some interferance π€·ββοΈTo build on https://github.com/storybookjs/storybook/issues/7914#issuecomment-595508641, may I suggest this is a bug (or at least documentation gap?) in the way Emotion is depended upon in Storybook? I donβt see any documentation stating that you must install it yourself, but for instance, having the following dependencies
Yields the following
UNMET PEER DEPENDENCYerror:npm install --save-dev @emotion/core@^10.0.27alleviates the problem:and fixes the bug from this issue.
Update: I had previously run
npx npm-check-updates '/storybook/' -uwhich seemed to bump me to@storybook/addon-docs": "^5.2.0-alpha.33which I hadnβt realised. I manually changed that to@storybook/addon-docs": "^5.2.5and thennpm installandnpm i --package-lock-onlyand can now access the docs page free of errors.New lock file donβt help me π
@shilman - tried adding
"@storybook/theming": "^5.2.3",and still getting:I donβt know whatβs causing this, but we had the same issue. I pared it down to markdown looking like this (thatβs double-indented text):
Converting it to a simple bullet list makes that error go away.
Hi @honorsuper , Yes, I resolved it. Try to remove package-lock/yarn lock files. It should help
thanks @shilman - I ended up ripping all the storybook related packages out of my package.json, and ran sb init from scratch and slowly re-added each storybook addon. Itβs working perfectly now β¨
@pierrenel @Iuriy-Budnikov 99% sure this is the symptom of a version mismatch / yarn issue. Iβm not sure whatβs the best way to diagnose/fix, but Iβve seen and fixed this in dozens of different storybooks.
When trying to use the new Storybook Docs I am gettig
theme.color is undefinedand a new lock file didnβt help me.There seem to be different versions of
@storybook/themingbeing referenced. If I runnpm list @storybook/themingI get:I then
npm i -D @storybook/themingandnpm i --package-lock-onlyand thennpm list @storybook/themingandnpm list @emotion/coreI get:These are my other config files just for reference:
package.json
.storybook/addons.js
.storybook/config.js
.storybook/webpack.config.js
Iβm running into this too after upgrading us to 5.2.4 and starting to move us away from storiesOf and toward CSFs. This happens for all stories (both CSF and storiesOf based stories, none are yet using MDX), and only when clicking the Docs tab. Hereβs all the debugging info I could gather for yβall, unfortunately the repo is private.
Note: I have not yet tried installing
"@storybook/theming"as a possible work-around, but will return here to update if that changes anything.Packages
Config
Note: Iβve removed all of the
addDecoratorcalls and stripped this just down to thereqandconfigurecall, and the error remains the same.Displayed Error
Cannot read property βlightestβ of undefined
Console Error
Having the same issue here π¦