-
-
Notifications
You must be signed in to change notification settings - Fork 897
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
[v6] Module parse failed: Unexpected character '#' when using Create-React-App #1043
Comments
Hmmm, tried running 6.0.0-beta.3 with my Create React App 5 sample app and it went without any issues. I suspect react-scripts 3.4.4 might be a bit too old 🤔 |
Same issue here. Any chances to get some help with this? |
Maybe it's possible to update Babel manually? I hope they didn't pin Babel version in CRA? |
Hello, I am on react-scripts 4.0.3 and I have the very same problem. |
We have tests for CRA 5, CRA 4 might need additional configuration which I haven't discovered yet |
This is my code import "react-pdf/dist/esm/Page/AnnotationLayer.css"; const PdfPreview = ({ data }) => { const onDocumentLoadSuccess = ({ numPages }) => { const goToPrevPage = () => const goToNextPage = () => return ( |
Hi all, I have tested combinations and they work on environment and packages: other packages for assist compile: |
same thing in storybook
I also tried to add |
Another data point; I'm seeing this with:
|
@victors1681 |
Did you figure out any solution? I have also this same issue :( |
also have same issue |
Had the same issue and found no solution (had to revert to react-pdf version 5.0.0) |
I think that this problem is not specific to Edit: I've just realized that this comment would be more appropriate for https://github.com/mozilla/pdfjs-dist. |
Ok, so apparently
Perhaps it would be more prudent if |
Legacy builds were dropped in #988. One of the main reasons was that this made the code insanely big and this kept crashing people's machines due to out of memory errors. |
@wojtekmaj, getting the same error here:
Oddly enough it was working until I changed branches and it was totally broken when I switched back. edit: I tried rolling back to 5.7.2 and still getting the same error, unless 6.2.0 is cached or something weird. The error goes away when I comment the import statement out: Also, I'm using Chrome: 108.0.5359.98, but that shouldn't make a difference since this fails during the compilation step. |
I've had this error on react-pdf above Currently running on: |
Anyone have any build solutions? |
I managed to get I found using the const np = require('path')
module.exports = {
// ...
module: {
// ...
rules: [
{
test: /\.(mjs|jsx|js)$/,
include: [
np.resolve('src'),
// babel-env has all the presets to build pdfjs, just needs to be included
np.resolve('node_modules/pdfjs-dist/build'),
],
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
configFile: false,
presets: [
'@babel/preset-env',
// ....
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
// ...
],
},
},
],
},
],
},
} I hope that helps someone that was also stuck on the |
did anyone happen to get react-pdf 6.2.2 working via webpack 4? the recommendation below of @Nubuck didn't help. thanks. |
This is still failing... |
@evanjmg Update to webpack 5 it should solve this issue. |
Hola! |
G'day - wondering if there is an ETA for this bug to be fixed? TIA |
I had same issue in my React app with react-scripts 4.0.3 Sample usage
|
I was getting this issue in another library
I added |
If you want to solve this problem you need to switch to "react-pdf": "^5.3.2" version, this issure may be helpful for you, or see my codebox !!!!If the codebox runs incorrectly, it is possible to export the project run!!!! |
I have this problem too, when I upgrade
|
./node_modules/pdfjs-dist/build/pdf.js 1198:17
| constructor() { react: 17.0.2, |
just use 5.3.2 |
But I need to use "devicePixelRatio" this props. |
It really works. |
import { Document, Page, pdfjs } from "react-pdf"; if you use create-react-app ,must add this |
This solution works for me, thanks a lot buddy! |
Anything fixed in version 6? |
I fix this issue via updating react-scripts from |
CRA 4 is now 2.5 years old, CRA 5 is almost 2 years old. I have no intention or capacity of supporting v4. If you need to use React-PDF with CRA 4, use older React-PDF versions. |
I am using v7.3.3, but still getting this error. ModuleParseError: Module parse failed: Unexpected character '' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) |
Nevermind, it works. The library looks good. |
How did you make it work? |
This was really helpful, thanks! |
one possible solution,
Also set webpack.config.js works good with webpack 4 and react 16 for react-pdf V6, if want to use V7 please use webpack5 |
Version5 has a case when I view one of a pdf files, It cause browser slow, lagging, and make it doesn't reposne. I've fixed the problem with upgrade to version 6 and found Module parse failed: Unexpected character '#'. when i update my nextjs version to "next": "^11.1.4" it fixed the error. |
add |
This solution worked for me. I installed "babel-loader": "^8.3.0" and added the below code into next.config.js (I use next.js 9.5.5) config.module.rules.push({ Thank you so much!!!! |
Another solution is using esbuild-loader with target es2015 , seems to fix most stuff. I specifically needed this line to make it work
Babel seemed to be way messier This is using |
Before you start - checklist
Description
Our team is waiting for a new version of react-pdf with a new build of pdfjs-dist, which has a fix for Hebrew, so for the test, we tried to install the 6th version of react-pdf but after installation we got the following error
Steps to reproduce
install
react-pdf 16 or 17
react-scripts: 3.4.4
implement react-pdf@v6.0.0-beta.3
Expected behavior
Actual behavior
Additional information
how can we solve this problem? Thank you
DEMO
Environment
The text was updated successfully, but these errors were encountered: