WebpackError: window is not defined
See original GitHub issueWhen trying to use materialize with GatsbyJS and deploying to Netlify I get the following error when building the project: WebpackError: window is not defined
1:04:37 PM: WebpackError: window is not defined
1:04:37 PM:
1:04:37 PM: - materialize.min.js:6 Object.module.exports.layoutContext
1:04:37 PM: ~/materialize-css/dist/js/materialize.min.js:6:1135
1:04:37 PM:
1:04:37 PM: - index.js:6 Object.exports.__esModule
1:04:37 PM: src/layouts/index.js:6:1
1:04:37 PM:
1:04:37 PM: - index.js:3 Object.exports.__esModule
1:04:37 PM: .cache/layouts/index.js:3:3
1:04:37 PM:
1:04:37 PM: - sync-requires.js:6 Object.exports.__esModule
1:04:37 PM: .cache/sync-requires.js:6:35
1:04:37 PM:
1:04:37 PM: - static-entry.js:8 Object.<anonymous>
1:04:37 PM: .cache/static-entry.js:8:1
The sample project is here: https://github.com/vojtechruz/staticman-example
The failed build log here: https://app.netlify.com/sites/staticman-example/deploys/5b81377f4ed62f240de8d134
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Gatsby - the window is not defined error, what and how to fix it?
The nodejs environment doesn't have the browser-globals like window , document , etc. Hence if the source code has a reference to them,...
Read more >Window is not defined · Issue #309 · gatsbyjs/gatsby - GitHub
Works fine in development but if I try to gatsby build , I get Error: ReferenceError: window is not defined . I'm doing...
Read more >WebpackError: ReferenceError: window is not defined on Gatsby
When using third-party dependencies (such as your Bootstrap modal) your capability to access to window object disappears.
Read more >ReferenceError: Window Is Not Defined in GatsbyJS
Debugging why your GatsbyJS (or NextJS) build is failing when you receive the message 'window is not defined'.
Read more >Solve window is not defined in Next.js - YouTube
In this video I am going to show you how to solve window is not defined problem that you are facing when using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The only issue with gatsby js v2 it that I haven’t figured out how to make the waves effect work in production builds.
Did anyone figure out a workaround for this? I’m also trying to import
materialize-css
(trying to usewaves
specifically) into my Gatsby app. Not having any luck. Tried importing it inside auseEffect
but that doesn’t appear to work. Which seems weird because this works forscrollspy
:But for whatever reason, I cannot get
waves
to work using this same import.Update:
Got waves to work by adding this inside the above
import.then
: