Skip to content

Error when using tfjs-node with Angular #753

@JonasJW

Description

@JonasJW

Describe the problem or feature request

I'm trying to save my model in a file with Angular 6. I expected it to work just like a normal Node.js project but I get these errors:

WARNING in ./node_modules/bindings/bindings.js 81:22-40 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/bindings/bindings.js 81:43-53 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js Module not found: Error: Can't resolve 'crypto' in '/Users/jonas/Projects/ML/tfjs-test/ng-tfjs-mobilenet-extend/node_modules/@tensorflow/tfjs-core/dist'

ERROR in ./node_modules/@tensorflow/tfjs-node/dist/io/file_system.js Module not found: Error: Can't resolve 'fs' in '/Users/jonas/Projects/ML/tfjs-test/ng-tfjs-mobilenet-extend/node_modules/@tensorflow/tfjs-node/dist/io'
ERROR in ./node_modules/bindings/bindings.js Module not found: Error: Can't resolve 'fs' in '/Users/jonas/Projects/ML/tfjs-test/ng-tfjs-mobilenet-extend/node_modules/bindings'
ERROR in ./node_modules/@tensorflow/tfjs-node/dist/io/file_system.js Module not found: Error: Can't resolve 'path' in '/Users/jonas/Projects/ML/tfjs-test/ng-tfjs-mobilenet-extend/node_modules/@tensorflow/tfjs-node/dist/io'
ERROR in ./node_modules/bindings/bindings.js Module not found: Error: Can't resolve 'path' in '/Users/jonas/Projects/ML/tfjs-test/ng-tfjs-mobilenet-extend/node_modules/bindings'

Code to reproduce the bug / link to feature request

This is my code:

import { Component } from '@angular/core';
import * as tf from '@tensorflow/tfjs';
import '@tensorflow/tfjs-node';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';

  constructor() {
    const model = tf.sequential();
    model.add(tf.layers.dense({units: 1, inputShape: [1]}));
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions