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

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #415

Closed
2208Abhinav opened this issue Jun 22, 2019 · 7 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@2208Abhinav
Copy link

2208Abhinav commented Jun 22, 2019

./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.

@2208Abhinav
Copy link
Author

2208Abhinav commented Jun 22, 2019

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.

@fippli
Copy link

fippli commented Jul 2, 2019

I got the same problem when installing according to README. I also created the app with create-react-app

@anuveyatsu
Copy link

Same here

@illiakovalenko
Copy link

illiakovalenko commented Jul 3, 2019

Copy of - #280, everyone are waiting for a fix :)

@wojtekmaj wojtekmaj added bug Something isn't working duplicate This issue or pull request already exists question Further information is requested and removed bug Something isn't working labels Sep 15, 2019
@wojtekmaj
Copy link
Owner

Duplicate of #280

@wojtekmaj wojtekmaj marked this as a duplicate of #280 Sep 15, 2019
@BenOron
Copy link

BenOron commented May 26, 2020

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.

@wojtekmaj
Copy link
Owner

To anyone watching this thread instead of #280: See #280 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants