React production build will not compile TensorFlow.js 2.0
See original GitHub issueTo get help from the community, we encourage using Stack Overflow and the tensorflow.js
tag.
2.0 TensorFlow.js version
Chrome Version 83.0.4103.61 (Official Build) (64-bit)
Hello, when building the react app in Development mode the tensorFlowJS 2.0 model worked just fine, but when using the built version from reactjs, I get an error related to tensorflow,
Uncaught (in promise) TypeError: Cannot call a class as a function at r (classCallCheck.js:3) at new e (tensor.ts:395) at e.value (engine.ts:714) at l (tensor_ops.ts:113) at c (tensor_ops.ts:59) at Module.d (io_utils.ts:180) at e.<anonymous> (graph_model.ts:128) at s (runtime.js:45) at Generator._invoke (runtime.js:274) at Generator.forEach.e.<computed> [as next] (runtime.js:97)
[solution] rolled back tensorFlowJS version 1.0.1 and it compiled for production. We were never able to pinpoint the problem but I thought I should flag this.
GitHub issues for this repository are tracked in the tfjs union repository.
Please file your issue there, following the guidance in that issue template.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:43 (6 by maintainers)
Top GitHub Comments
I was facing the same issue in my production build of react app where a tensorflowjs model was being loaded. I am using create-react-app v3.4.1 and
@tensorflow/tfjs 2.0.0
in my project. As per @tafsiri’s diagnosisI was able to rebuild and run my app in production by ejecting my
react-app
and adding the following to myconfig/webpack.config.js
As far as I understand, when we do
import * as tf from '@tensorflow/tfjs'
import using * we need to let webpack know that the module will be found in['main']
Ref: https://webpack.js.org/configuration/resolve/#resolvemainfieldsThis issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 dyas if no further activity occurs. Thank you.