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.

[tfjs-react-native] Can't import tensorflow when creating project with react native CLI

See original GitHub issue

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: Pixel C API 30 (Emulator)
  • TensorFlow.js installed from (npm or script link): https://www.npmjs.com/package/@tensorflow/tfjs
  • TensorFlow.js version: @tensorflow/tfjs@3.9.0
  • CUDA/cuDNN version: 11.1

Describe the problem I tried following the instructions for installing tfjs-react-native on a completely new project created with React Native CLI: https://www.npmjs.com/package/@tensorflow/tfjs-react-native.

After completing the installation, I try to import tfjs with these lines in App.js:

import * as tf from '@tensorflow/tfjs'; import '@tensorflow/tfjs-react-native';

I get the following error:

ERROR Error: Cannot evaluate flag 'DEBUG': no evaluation function found.

This does not happen when I set up the project with Expo instead of the React Native CLI. However, I need to find a fix for the problem because I need tfjs-react-native for an existing project that is not set up with Expo. I initially ran into the same issue on the original project, so this is why I created a blank project to investigate the issue.

Provide the exact sequence of commands / steps that you executed before running into the problem

Setting up the project:

react-native init TestProject cd TestProject npm install react-native-unimodules npm install expo-gl-cpp expo-gl npm install expo-camera npm install @react-native-async-storage/async-storage npm i react-native-fs npm install @tensorflow/tfjs npm install @tensorflow/tfjs-react-native

Then, I import tensorflow in App.js as mentioned above and run the app with: react-native run-android

Any other info / logs Error: ERROR Error: Cannot evaluate flag 'DEBUG': no evaluation function found.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
bobanminic96commented, Jun 7, 2022

I couldn’t find a concrete answer to the question. Does tensorflow support react-native CLI, or it supports only EXPO projects ? Thanks!

1reaction
andrekovaccommented, Jan 25, 2022

@mmilenkoski can you please check out similar issue here #5179 (comment) ?

@rthadur thank you for the response! That does solve the issue but is there a way to merge the original metro.config.js file and the changes required from tfjs? Here is my original content:

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
}

@mmilenkoski Did it work for you with inlineRequires: false? I’m getting the same behavior as you do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to resolve module react-native-fs - Stack Overflow
Now I'm trying to make image classification but I'm getting this error after installing: @tensorflow/tfjs-react-native --legacy-peer-deps.
Read more >
Installation error of @tensorflow/tfjs-react-native - TF.js
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle...
Read more >
tensorflow/tfjs-react-native v0.8.0 - npm.io
Step 1. Create your react native app. · Step 2: Install dependencies · Step 3: Configure Metro · Step 4: Test that it...
Read more >
React Native + Tensorflow.js - implementing a model - Medium
>npm i @tensorflow/tfjs-react-native. The implementation is done in four steps: Transform the model so it can be loaded onto the device and ...
Read more >
Build React Native App with TensorFlow.js and MobileNet ...
This is the second part of the series, explaining how to create a react native application based on TensorFlow.js model we created on...
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