Window is not defined error when using worker
See original GitHub issueHi,
I am currently using Papa Parse with npm, which I then import into my React file using:
import * as Papa from 'papaparse';
I’m using an upload button on the front-end to pass the file to React and using Papa Parse to parse CSV files. All works fine with small files but I realized with large ones, I’d need to use a worker or else the browser crashes. However adding the worker parameter is causing an error in the console. See below for reference:
Papa.parse( file, {
worker : true,
header : false,
skipEmptyLines: 'greedy',
step : function( results ) {
console.log( 'Result:', results.data );
},
complete : function( results ) {
console.log('Complete', results);
}
} );
Without the worker, the error goes away - any idea how to troubleshoot this? Is it my local environment or the way Papa Parse is set up in my project? Thanks!
If it helps, the CSV file I’m testing with is the “large file” from Papa Parse’s “local file” demo here: https://www.papaparse.com/demo
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
"window is not defined" service worker - Stack Overflow
I was writing the code: // App install banner window.addEventListener('beforeinstallprompt', function(e) { e.
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 >window is not defined when using Workers · Issue #153 - GitHub
I get an error as in title. I thought this library was supposed to be compatible with node.js. So why use window? Actually,...
Read more >How to solve "window is not defined" errors in React and Next.js
First solution: typeof Because typeof won't try to evaluate "window", it will only try to get its type, in our case in Node....
Read more >Uncaught ReferenceError: window is not defined - Workers
Look in the library that you're importing then - your code is running in a server-side context, like Node, not in a user's...
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
Probably you need to set the PAPA_SCRIPT path variable as explained on the Can Papa Parse be loaded asynchronously (after the page loads)? section of our faq
I’m now successfully using worker with PapaParse.
Here are the final steps that worked for me.
var Papa = require(“papaparse”); Papa.SCRIPT_PATH = “./papaparse.js”;