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.

`window` is not defined in worker file

See original GitHub issue

This is not really an issue with vue-pdf but I ran into this recently and tought it may be worth sharing. When using vue-pdf with Webpack 4 (e.g. a project created by vue-cli v3) the dev build with hot reloading gave the following error message:

window is not defined in worker[hash].js

and vue-pdf did not display anything.

This only occurs on development builds with hot reloading, on production it is fine. After investigating I found the following issue to be the reason why this happens: https://github.com/webpack/webpack/issues/6642

Until this is fixed in webpack the following workaround did work for me. In the Webpack config set the following option:

 output: {
  globalObject: 'this'
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
coreycoburncommented, Feb 14, 2019

In Nuxt, you can get this to work in nuxt.config.js:

extend(config, ctx) {
  config.output.globalObject = 'this'
}
9reactions
nothingismagickcommented, Jan 18, 2019

If you end up here via the Quasar framework, you can use chainWebpack in your quasar.conf.js:

    build: {
      chainWebpack(chain) {
        chain.output.set('globalObject', 'this')
Read more comments on GitHub >

github_iconTop Results From Across the Web

"window is not defined" service worker - Stack Overflow
I don't know if it is related but in the Application tab, the service worker doesn't show the file name but shows (index)....
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 >
Cannot access window in sw.js · Issue #1482 - GitHub
Failed doing this thing console.log('window...', window) in file sw.js that generated by workbox v3.2.0. It always return undefined.
Read more >
How To Solve ReferenceError window is not defined in ...
Fixing a window is not defined error can be quite simple. In most cases, all you will need to do is wrap your...
Read more >
How to solve "window is not defined" errors in React and Next.js
Because in the Node.js world, window is not defined, window is only available in browsers. There are three ways to solve that: 1....
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