./node_modules/pdfjs-dist/build/pdf.js | Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
I get the above error on npm start
I installed react-pdf as mentioned in the docs.
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8"
above is the structure of package.json and I installed react-pdf version 4.1.0
I used create-react-app to make the app.
By doing pdfjs.GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js"; I have managed to display the pdf but still the above mentioned warning is coming.
I got the same problem when installing according to README. I also created the app with create-react-app
Same here
Copy of - https://github.com/wojtekmaj/react-pdf/issues/280, everyone are waiting for a fix :)
Duplicate of #280
My full workaround.
Create a file at the root called config-overrides.js and it should contain the following:
module.exports = function override(config) {
config.module.rules[0].parser.requireEnsure = true
return config
};
After that npm i react-app-rewired to you app and change your build function in package.json to read react-app-rewired build/react-app-rewired start.
That should do it for now.
To anyone watching this thread instead of #280: See https://github.com/wojtekmaj/react-pdf/issues/280#issuecomment-641590816.
Most helpful comment
Copy of - https://github.com/wojtekmaj/react-pdf/issues/280, everyone are waiting for a fix :)