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

Cannot read property 'matchMedia' of undefined -- window is undefined #192

Open
edda opened this issue Nov 2, 2022 · 0 comments
Open

Cannot read property 'matchMedia' of undefined -- window is undefined #192

edda opened this issue Nov 2, 2022 · 0 comments

Comments

@edda
Copy link

edda commented Nov 2, 2022

After upgrading storybook/react to 6.5.13 (from 6.4.22) I suddenly have problems with storybook-dark-mode not wanting to load because window is undefined. See the full callstack below. I was on [email protected], upgraded to 1.1.2. Same error in both versions.

I'm using webpack5, [email protected]

Any ideas what could be going wrong here?

Failed to load preset: {"type":"presets","name":"/app/.yarn/__virtual__/storybook-dark-mode-virtual-6715300bd7/0/cache/storybook-dark-mode-npm-1.1.2-ecc4605688-8.zip/node_modules/storybook-dark-mode/dist/index.js"} on level 1
ERR! TypeError: Cannot read property 'matchMedia' of undefined
ERR!     at Object.<anonymous> (/app/.yarn/__virtual__/storybook-dark-mode-virtual-6715300bd7/0/cache/storybook-dark-mode-npm-1.1.2-ecc4605688-8.zip/node_modules/storybook-dark-mode/dist/Tool.js:64:30)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (/app/.pnp.cjs:48904:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at Object.<anonymous> (/app/.yarn/__virtual__/storybook-dark-mode-virtual-6715300bd7/0/cache/storybook-dark-mode-npm-1.1.2-ecc4605688-8.zip/node_modules/storybook-dark-mode/dist/index.js:28:14)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (/app/.pnp.cjs:48904:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at interopRequireDefault (/app/.yarn/__virtual__/@storybook-core-common-virtual-5880bee6e4/0/cache/@storybook-core-common-npm-6.5.13-49981d30f1-8.zip/node_modules/@storybook/core-common/dist/cjs/presets.js:178:16)
ERR!     at getContent (/app/.yarn/__virtual__/@storybook-core-common-virtual-5880bee6e4/0/cache/@storybook-core-common-npm-6.5.13-49981d30f1-8.zip/node_modules/@storybook/core-common/dist/cjs/presets.js:194:10)
ERR!  TypeError: Cannot read property 'matchMedia' of undefined
ERR!     at Object.<anonymous> (/app/.yarn/__virtual__/storybook-dark-mode-virtual-6715300bd7/0/cache/storybook-dark-mode-npm-1.1.2-ecc4605688-8.zip/node_modules/storybook-dark-mode/dist/Tool.js:64:30)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (/app/.pnp.cjs:48904:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at Object.<anonymous> (/app/.yarn/__virtual__/storybook-dark-mode-virtual-6715300bd7/0/cache/storybook-dark-mode-npm-1.1.2-ecc4605688-8.zip/node_modules/storybook-dark-mode/dist/index.js:28:14)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.external_module_.Module._load (/app/.pnp.cjs:48904:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at interopRequireDefault (/app/.yarn/__virtual__/@storybook-core-common-virtual-5880bee6e4/0/cache/@storybook-core-common-npm-6.5.13-49981d30f1-8.zip/node_modules/@storybook/core-common/dist/cjs/presets.js:178:16)
ERR!     at getContent (/app/.yarn/__virtual__/@storybook-core-common-virtual-5880bee6e4/0/cache/@storybook-core-common-npm-6.5.13-49981d30f1-8.zip/node_modules/@storybook/core-common/dist/cjs/presets.js:194:10)
@edda edda changed the title Cannot read property 'matchMedia' of undefined -- window is null Cannot read property 'matchMedia' of undefined -- window is undefined Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant