Skip to content

window is not defined error #352

@vojtechruz

Description

@vojtechruz

Do you want to request a feature or report a bug?
bug

What is the current behavior?
When I deploy my GatsbyJs application to netlify, and I import Docs Search I get:


11:47:21 AM: See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
11:47:21 AM:   3 | (function(global, factory) {
11:47:21 AM:   4 |   module.exports = factory(global);
11:47:21 AM: > 5 | }(/* this ##### UPDATED: here we want to use window/global instead of this which is the current file context ##### */ window, function(window) {
11:47:21 AM:     |  ^
11:47:21 AM:   6 |   var Zepto = (function() {
11:47:21 AM:   7 |   var undefined, key, $, classList, emptyArray = [], concat = emptyArray.concat, filter = emptyArray.filter, slice = emptyArray.slice,
11:47:21 AM:   8 |     document = window.document,
11:47:21 AM: 
11:47:21 AM:   WebpackError: window is not defined
11:47:21 AM:   
11:47:21 AM:   - zepto.js:5 Object.module.exports.element
11:47:21 AM:     ~/autocomplete.js/zepto.js:5:2
11:47:21 AM:   
11:47:21 AM:   - index.js:4 Object.<anonymous>
11:47:21 AM:     ~/autocomplete.js/src/standalone/index.js:4:1
11:47:21 AM:   
11:47:21 AM:   - index.js:3 Object.<anonymous>
11:47:21 AM:     ~/autocomplete.js/index.js:3:1
11:47:21 AM:   
11:47:21 AM:   - DocSearch.js:19 Object.<anonymous>
11:47:21 AM:     ~/docsearch.js/dist/npm/src/lib/DocSearch.js:19:1
11:47:22 AM:   
11:47:22 AM:   - main.js:11 Object._bind
11:47:22 AM:     ~/docsearch.js/dist/npm/src/lib/main.js:11:1

}(/* this ##### UPDATED: here we want to use window/global instead of this which is the current file context ##### */ window, function(window) {  

My code is here:
https://github.com/vojtechruz/vojtechruzicka-blog/blob/master/src/components/SearchBox.js

Full error log here:
https://app.netlify.com/sites/vojtechruzicka/deploys/5b17acd1c965921b0450d558

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions