question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[worker-loader] window is not defined

See original GitHub issue

Version

3.0.1

Reproduction link

https://github.com/screendriver/vue-cli-worker-loader-bug

Node and OS info

Node 10.9.0 / yarn 1.9.4 / macOS high sierra

Steps to reproduce

Just do a yarn serve and open http://localhost:8080 in your browser. You can see the error immediately.

What is expected?

Should not throw Uncaught ReferenceError: window is not defined.

What is actually happening?

Throws the error and doesn’t work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ngohuunamcommented, Aug 20, 2018

this work for me, add to vue.config.js configureWebpack: { output: { globalObject: 'this', }, },

2reactions
Hebiliciouscommented, Aug 20, 2018

I ran into similar issues in a worker-loader + webpack-worker-wrapper setup. You can work around it by adding this to your vue.config.js :

module.exports = {
  chainWebpack: config => {
    config.output.globalObject('this')
  }
}

… and doing something like this in your worker.js files :

import workerGlobals from './workerGlobals.js'

and in workerGlobals.js

//Comment the lines you don't need.
global.process = process
window = undefined
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 4.0.1 | WebWorker window is not defined #6642
When requiring web-worker (using worker-loader) recieve error Uncaught ReferenceError: window is not defined .
Read more >
Webpack worker-loader - import doesn't work - Stack Overflow
I understand that my problem is that window is not defined in web workers. The problem is that this error appear when I...
Read more >
"not defined" window in web worker. Is this a bug?
I am running into an issue trying to load a model into a web-worker via the indexedDB. Specifically, I am getting a ReferenceError:...
Read more >
#5 - Does not work in web worker - atob.js - CoolAJ86 on GIT
Uncaught ReferenceError : window is not defined browser-atob.js:44 ... Is atob defined on... self or whatever it is that workers have? Does globalThis...
Read more >
Web Workers API - Web APIs - MDN Web Docs - Mozilla
While Window is not directly available to workers, many of the same methods are defined in a shared mixin ( WindowOrWorkerGlobalScope ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found