question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

17reactions
illiakovalenkocommented, Jul 3, 2019

Copy of - https://github.com/wojtekmaj/react-pdf/issues/280, everyone are waiting for a fix 😃

5reactions
BenOroncommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Critical dependency: require function is used in a way in which ...
Critical dependency : require function is used in a way in which dependencies cannot be statically extracted · Subscribe to RSS.
Read more >
Critical dependency: require function is used in a way ... - GitHub
The error originates from the esm target, which should not have any require statements. It'd be nice to explore that built module and...
Read more >
Incompatible with Webpack - Google Groups
"require function is used in a way, in which dependencies cannot be statically extracted" These errors come when trying to "require" specific modules, ......
Read more >
Node.js – WARNING in Critical dependency: require function ...
Node.js – WARNING in Critical dependency: require function is used in a way in which dependencies cannot be statically extracted. angularnode.jswebpack.
Read more >
Critical dependency: require function is ... - Auth0 Community
Critical dependency : require function is used in a way in which dependencies cannot be statically extracted ; samueljbarrick May 4, 2020, 10:28pm ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found