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

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

Open
WCH-Jason opened this issue Oct 8, 2024 · 5 comments · May be fixed by #783

Comments

@WCH-Jason
Copy link

This warning occurred after I built and ran yarn, and I asked GPT that it could be ignored if it did not affect the operation of the project, but after I turned off the warning, nothing could be displayed on the web page (blank page)
屏幕截图 2024-10-08 145249
屏幕截图 2024-10-08 151802
屏幕截图 2024-10-08 151922

@Beasleydog
Copy link

Did you figure this out?

@moersxm
Copy link

moersxm commented Oct 12, 2024

i got the same problem

@whut-zhangwx
Copy link

+1, same problem

HendricksJudy added a commit to HendricksJudy/segment-anything that referenced this issue Oct 21, 2024
Fixes facebookresearch#777

Replace `require` statements with `import` statements in Webpack configuration files to resolve the critical dependency warning and blank page issue.

* **`demo/configs/webpack/common.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/dev.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/prod.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.
@TonyLianLong
Copy link

TonyLianLong commented Nov 1, 2024

The solution is to update package.json to use "onnxruntime-web": "1.14.0", (rather than "onnxruntime-web": "^1.14.0", as it is in the repo). This will ensure v1.14.0 to be installed. Then rerun yarn to install the right version of the package. I also find that the onnx needs to be exported with onnx==1.13.1 and onnxruntime==1.13.1 rather than the latest versions of these two packages. These two are python packages that can be installed with pip.

@takerfume
Copy link

takerfume commented Nov 7, 2024

@TonyLianLong
This helped me!

In addition, when I use python 3.12 and numpy 2.x, this demo didn't work.
But when I use python 3.10.5 and numpy 1.23.3, it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants