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.

ES6 Module Import of Tensorflow no longer works

See original GitHub issue

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

Tensorflow Core 2.1.0

Browser version

Doesn’t matter, but Chrome 85

Describe the problem or feature request

Previously, with Tensorflow (ex 1.3.2), I could use ES6 module imports along with a simple bare-module resolving server like es-dev-server (https://www.npmjs.com/package/es-dev-server), or quite possibly the Chrome only import maps.

Unfortunately, now, that’s not possible. It looks like the newer dependency tfjs-backend-cpu contains a seedrandom import, and this module is not a proper ES6 import (uses require() for importing). Perhaps this small module could be bundled as an ES6 import prior to shipping such that it all works again?

thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
AmitMYcommented, Apr 20, 2022

This is still an issue.


Using Angular (webpack), it is possible to import, but the following message is given: tfjs 3.16.0

Warning: \node_modules@tensorflow\tfjs-backend-cpu\dist\kernels\Multinomial.js depends on ‘seedrandom’. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: \node_modules@tensorflow\tfjs-core\dist\ops\rand_util.js depends on ‘seedrandom’. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

0reactions
mattsoulanillecommented, Jun 7, 2022

Here’s the branch where I’m working on this. If you want to try it locally, you can build local npm packages from it by running yarn build in link-package. The outputs show up in link-package/node_modules/@tensorflow/.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use import statement outside a module when trying to ...
I ran npm install @tensorflow/tfjs like explained here which worked; I tried to import it like so: import * as tf from '@tensorflow/tfjs';....
Read more >
TensorFlow.js in Node
When importing TensorFlow.js from this package, the module that you get will be accelerated by the TensorFlow C binary and run on the...
Read more >
Error when importing TensorFlow | Apple Developer Forums
When I try to import tensorflow: import tensorflow. I get the following error: RuntimeError: module compiled against API version 0xe but this version...
Read more >
How to use an ES6 import in Node.js? - GeeksforGeeks
Node has experimental support for ES modules. To enable them we need to make some changes to the package.json file. Before following the...
Read more >
import "tensorflow.keras.models" could not be resolved
AttributeError: module 'os' has no attribute 'envirion'. It can be resolved if you can correct spell to environ. Working code as shown below....
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