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.

React production build will not compile TensorFlow.js 2.0

See original GitHub issue

To 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:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:43 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
avroshkcommented, Jun 12, 2020

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 diagnosis

It depends on your bundler, and i’m not super current on what is used in react at the moment. For example in webpack resolve.mainFields can be used.

I was able to rebuild and run my app in production by ejecting my react-app and adding the following to my config/webpack.config.js

resolve: {
      mainFields: ['main'],
      ....
}

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/#resolvemainfields

8reactions
google-ml-butler[bot]commented, Jul 28, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Production Build Will Not Compile Tensorflow.Js
This workflow created on GitHub Actions will be responsible for automatically test the Build is used for production builds and devbuild for nonminified...
Read more >
Setup | TensorFlow.js
Installation from NPM and using a build tool like Parcel, WebPack, or Rollup. If you are new to web development, or have never...
Read more >
Platform and environment | TensorFlow.js
js executes operations on the GPU by running WebGL shader programs. These shaders are assembled and compiled lazily when the user asks to ......
Read more >
Importing a Keras model into TensorFlow.js
Importing a Keras model into TensorFlow.js is a two-step process. First, convert an existing Keras model to TF.js Layers format, and then ...
Read more >
Creates a tf.Tensor with the provided values, shape and dtype.
For performance reasons, functions that create tensors do not necessarily perform a copy of ... Reshape permuted to produce reshapedPermuted of shape [batch ......
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