`window` is not defined in worker file
See original GitHub issueThis 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:
- Created 5 years ago
- Reactions:7
- Comments:14 (2 by maintainers)
Top 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 >
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 Free
Top 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
In Nuxt, you can get this to work in
nuxt.config.js
:If you end up here via the Quasar framework, you can use chainWebpack in your quasar.conf.js: