-
-
Notifications
You must be signed in to change notification settings - Fork 876
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
Unexpected token < #52
Comments
Hey there! |
Hey, |
Which version are you on? In general, it's a bad idea to start the project without the worker. In version 2.x, I've put extra effort to make it as easy as possible to do properly, so you might consider an update. "Failed to load PDF file" is just a message shown to the user. You might want to catch the errors on your own - you have several props for that, please refer to README.md (they are usually called |
Thank you, I am using the 2.0.0-beta.4 For now I found a solution for it to work without the worker by adding .bind(this) to onDocumentLoad I think the worker problem might come from a routing problem from my Laravel set-up
Many thanks for your help! |
No worries. Here to help if you need anything in the future :) |
Hey @potioventures, for your information - v2.0.0 (non-beta) just went live! |
Have the same problem, without worker all works fine |
Hey @kolyasya. Do you mean unexpected token? Usually |
@wojtekmaj Yes. I'm using your package in my Meteor application, so it doesn't have Webpack, but works the same way. In this case I have an error:
If I switch to All works nice and as expected 👍 |
My problem here I think (and potentially @kolyasya) is to be able to specify the worker's location given we use a separate routing system. |
Same problem, how to fix it? |
@againksy, check in Network tab of developer tools what is actually loaded as pdf.worker.js. Chances are, it's a HTML 404 file which Webpack tries to parse as JS and obviously fails. Check instructions for handling workers in README.md closely. In case of any further questions write here! |
@wojtekmaj Thank you for this awesome module. @kolyasya I am using this in a meteor app as well. For anyone tackling this in Meteor here's what I did:
|
Hi. I'm getting the same "Uncaught SyntaxError: Unexpected token <" with Webpack. An inspection does take me to the top of my index.html file. I'm sure the worker isn't loading correctly. I went through the Readme for version 3.x (I tried installing @^4.0.0, but npm said it didn't exist; I'm using React 16.3.2.) I have the following line in my component — Is this what you mean in your readme, or is there a loader I should be adding into webpack.config? Or maybe I'm not doing something with cMaps? I'm not really clear what I may be doing wrong, even if it is a worker. Thanks for the assist. |
@mattblackdev thank you, it works! |
@abelsj60 4.0.0 doesn't exist just yet, but 4.0.0-beta does. I'm fairly confident about this one; you can check it out on React 16.3 and up. |
here is a little bit of my 2sense:
i hope this information is helpful for anyone trying to figure out, what's going on - or in the further development of version 4.0. i will also proceed to investigate later in time. PS.: Another fix i guess would be to follow @mattblackdev's solution but instead of step 2 or 3 to just load the worker from your public/index.html (not tested though). |
Hi, I'm getting the same Uncaught token < error. My pdf.worker.js is returning some HTML document. Link to codesandbox |
@jtibrewal09 You're requesting pdf.worker.js from a location that doesn't exists and you're getting a HTML with 404 error page instead of JS file. App tries to parse HTML file as a JS file and throws this error. You used Create-React-App, so you should follow Create-React-App instructions. In React-PDF 3.x, you will have to use |
Thank you so much @wojtekmaj for helping me out this quick. |
I am trying to import set options but it says it does not exist in the module |
setOptions is not a thing since 4.x. Use options prop passed to Document component. See details in README. |
Hi: Having the same problem, but setting pdf.worker.js doesn't work. Check it out here: |
Hey Guys, I lost some time on this issue, although its kind of simple. You need to process the worker.min.js with other packages through webpack, so at the end this is what I have. React component:
Webpack:
|
Hi, I'm getting this two errors : Deprecated API usage: render no longer accepts the I saw the others problems but I didn't found a solution |
For CRA (w/ Webpack 4), the only thing that worked for me in production (using an Azure App Service) was to reference an external CDN. (I didn't have to do anything special, though, when running on localhost.)
|
@devuxer hi after adding the same. I'm getting these two errors: |
@devuxer, worked for me. Thank u! |
when i try to upload pdf file i get this error |
Hi,
Thank you for maintaining this awesome package :)
I'm trying to use it in my React app but I get the following error in the console and the component is stuck on loading:
Uncaught SyntaxError: Unexpected token < http://project_server.dev/app_folder/d58d9dd3a5c5f2a8eafb.worker.js
I'm loading a base64 PDF served by my Laravel backend. I'm using webpack and everything seem properly set up. The base64 PDF seems file too.
Any idea what I'm doing wrong?
Many thanks
The text was updated successfully, but these errors were encountered: