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.

import tfjs-node and build via webpack,babel - error node-pre-gyp

See original GitHub issue

Hi, I’m trying to break tfjs-node in vain the next day. When compiling using a webpack, I get errors from the node-pre-gyp package. I tried all possible ways I found in the forums, but nothing helps. I tried downgrading tfjs-node to version 1.2.1, but also without effect. I also tried the node in 8. I import the package according to the example. Is there a bug in building with a webpack with a babel?

TensorFlow.js version

1.2.5

Node version

v10.16.0 (for test try v8.11.3)

OS

macOS Mojave 10.14.5 (18F132) processor: 2,7 GHz Intel Core i5

BUILD ERRORS

> adsplayertf@1.0.0 try /Users/jf/Documents/Work/adsPlayer TF/tf
> webpack && node ./build/main.js

Hash: ee4f65476382096ae2f8
Version: webpack 3.12.0
Time: 2852ms
        Asset     Size  Chunks                    Chunk Names
      main.js  2.85 MB       0  [emitted]  [big]  main
normalizer.js  47.7 kB       1  [emitted]         normalizer
   creator.js  5.73 kB       2  [emitted]         creator
 [147] ./node_modules/node-pre-gyp/lib ^\.\/.*$ 1.03 kB {0} [built]
 [170] ./dataset/creator.js 2.5 kB {2} [built]
 [171] ./src/index.js 4.62 kB {0} [built]
 [247] ./node_modules/node-pre-gyp/lib/util 160 bytes {0} [built]
 [248] ./node_modules/node-pre-gyp/lib 160 bytes {0} [built]
 [302] ./node_modules/@tensorflow/tfjs-node/dist 160 bytes {0} [built]
 [306] ./src/class/Normalize.js 1.54 kB {0} [built]
 [312] ./data/normalizer_values.json 392 bytes {0} [built]
 [313] ./data/normalized_dataset.json 645 kB {0} [built]
 [314] ./dataset/normalizer.js 2.04 kB {1} [built]
 [328] ./data/raw_data.json 1.13 kB {1} [built]
    + 318 hidden modules

WARNING in ./node_modules/node-pre-gyp/lib/util/versioning.js
17:20-67 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/node-pre-gyp/lib/util/versioning.js
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-pre-gyp/lib/pre-binding.js
20:22-48 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/node-pre-gyp/lib/pre-binding.js
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/@tensorflow/tfjs-node/dist/index.js
44:15-35 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-fetch/lib/index.es.js
Module not found: Error: Can't resolve 'encoding' in '/Users/jakubfrydrych/Documents/Work/adsPlayer TF/tf/node_modules/node-fetch/lib'
 @ ./node_modules/node-fetch/lib/index.es.js 141:11-30
 @ ./node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/io/file_system.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'node-gyp' in '/Users/jakubfrydrych/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib/util'
 @ ./node_modules/node-pre-gyp/lib/util/compile.js 29:28-55
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'npm' in '/Users/jakubfrydrych/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib/util'
 @ ./node_modules/node-pre-gyp/lib/util/compile.js 39:27-49
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-pre-gyp/lib/install.js
Module not found: Error: Can't resolve 'request' in '/Users/jakubfrydrych/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/install.js 28:18-36
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

WARNING in ./node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <!doctype html>
| <html>
| <head>
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

ERROR in ./node_modules/node-pre-gyp/lib/info.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/jf/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/info.js 14:14-32
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

ERROR in ./node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/jf/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/publish.js 18:14-32
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

ERROR in ./node_modules/node-pre-gyp/lib/unpublish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/jf/Documents/Work/adsPlayer TF/tf/node_modules/node-pre-gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/unpublish.js 16:14-32
 @ ./node_modules/node-pre-gyp/lib ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./src/index.js

package.json

{
  "name": "adsplayertf",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "scripts": {
    "build": "webpack",
    "create-data": "rimraf data && node ./build/creator.js",
    "normalize-data": "node ./build/normalizer.js",
    "prepare-dataset": "rimraf data && webpack && node ./build/creator.js 100 && node ./build/normalizer.js",
    "try": "webpack && node ./build/main.js",
    "watch:build": "webpack --watch"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "regenerator-runtime": "^0.12.1",
    "webpack": "^3.8.1"
  },
  "dependencies": {
    "@tensorflow/tfjs-node": "^1.2.5",
    "rimraf": "^2.6.3"
  }
}

top of main.js document, import tfjs-node

import * as tf from '@tensorflow/tfjs-node'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
rfourdiniercommented, Oct 9, 2020

@kangyizhang @jakubfrydrych hello , i am struggling with the exact same error

I do not understand what do you mean when you say that you have “installed tensorflow library”, should i install it from pip or put the Tensorflow C library folder somewhere ? how does tfjs-node know where my tensorflow C library is located ?

thank you very much

0reactions
playgroundcommented, May 19, 2021

I’m getting the same errors. webpack-node-externals didn’t help.

“devDependencies”: { “@types/node”: “^15.0.2”, “@typescript-eslint/parser”: “^4.22.1”, “awesome-typescript-loader”: “^5.2.1”, “dotenv”: “^9.0.0”, “jsonfile”: “^6.1.0”, “ts-loader”: “^9.1.2”, “ts-node”: “^9.1.1”, “typescript”: “^4.2.4”, “webpack”: “^5.36.2”, “webpack-cli”: “^4.6.0”, “webpack-node-externals”: “^3.0.0” }, “dependencies”: { “@tensorflow-models/mobilenet”: “^2.1.0”, “@tensorflow/tfjs”: “^3.6.0”, “@tensorflow/tfjs-node”: “^3.6.1”, “rxjs”: “^7.0.0” }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensorflow - Nodegyp failed to build even if it is installed
Can anyone tell me what I've done wrong? Update. So I looked through the error and found a tiny detail: this line: node-pre-gyp...
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 >
Environments for running AI in Node.js - IBM Developer
Explore some of the environments and back ends that are available to better run machine learning tasks in Node.js with TensorFlow.js.
Read more >
Tensorflow.js set up on Ubuntu 20.04
TensorFlow.js is a Javascript library to train and deploy ML models on browsers and Node.js. It takes several steps to set it up...
Read more >
@tensorflow/tfjs-node | Yarn - Package Manager
js. This repository provides native TensorFlow execution in backend JavaScript applications under the Node.js runtime, accelerated by the TensorFlow C binary ...
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