Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"window is not defined" error when worker is set to true #655

Closed
jjech opened this issue Apr 19, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@jjech
Copy link
Contributor

commented Apr 19, 2019

This is a duplicate of #585. When worker is set to true, main.chunk.js?papaworker throws an uncaught reference error: "window is not defined."

If this is a configuration issue, more information is needed about how to resolve it. In #585 @pokoli referenced Can Papa Parse be loaded asynchronously (after the page loads)? section of the FAQ, but the FAQ in its current state doesn't mention anything about the PAPA_SCRIPT path variable.

This appears to be a common problem when workers are enabled in PapaParse, as several users have been looking for help in #585.

Capture

@jjech

This comment has been minimized.

Copy link
Contributor Author

commented Apr 19, 2019

Related issues: #563 #566

When I set the SCRIPT_PATH manually, I get the following error:
papaparse?papaworker:1 Uncaught SyntaxError: Unexpected token <

Someone else experienced this issue, too...
https://stackoverflow.com/questions/53782542/papaparse-script-path-is-undefined

I think maybe we need to "use webpack to serve papaparsejs as static file, so do not wrap it with webpack module" as @tamnvt mentions in #566 but I don't quite understand this comment.

@jjech

This comment has been minimized.

Copy link
Contributor Author

commented Apr 19, 2019

Got it... here are the final steps that worked for me.

  1. Copied papaparse.js from node_modules/papaparse/ to my main app directory.
  2. Added the following lines to both App.js and index.js

var Papa = require("papaparse");
Papa.SCRIPT_PATH = "./papaparse.js";

@jjech jjech closed this Apr 19, 2019

@jjech

This comment has been minimized.

Copy link
Contributor Author

commented Apr 19, 2019

Actually, I'm going to reopen this as I think it should be documented on the FAQ. Feel free to close if you disagree...

@jjech jjech reopened this Apr 19, 2019

@pokoli

This comment has been minimized.

Copy link
Collaborator

commented Apr 23, 2019

@jjech it will be great if you add a PR documenting this behaviour.
This faq source code is available on the faq.html file on the docs folder.

@jjech

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

Excellent point @pokoli. I'll do that and close the issue with the PR.

@jjech

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

Merged PR #656, closing issue.

@jjech jjech closed this Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.