Closed haoyangnz closed 5 years ago
Workaround:
npm rebuild @tensorflow/tfjs-node --build-from-source
@haoyangnz what's the operating system you are using?
@kangyizhang macos mojave 10.14.6
@haoyangnz
@kangyizhang hi there, I got the same issue here.
v10.16.0
hi @imnaifu can you provide what's the operating system you are using? can you successfully run the official tfjs-node example?
Hey @kangyizhang, it looks like I'm having the same issues.
Node v10.16.3
Npm 6.9.0
Mac OS 10.14.6
- MacBook Pro
Successfully ran tfjs-node example
I'm using tfjs in a Vue.js / Electron app. I just factory restored my machine, on which everything was working before the reset. I also got this error on another MacBook ( Air ) which I had been using as a loner.
I'm also getting node-gyp
errors, which seems to be related.
node-pre-gyp info This Node instance does not support builds for N-API version 4
This error occurs when I run my app for development using npm run electron:serve
.
I have verified I have xcode-cli tools installed. Default Python 2.7.x
is installed. I have cleared npm cache
and node_modules
a multiple times.
Are there any C/C++ dependencies I should check for?
I also got some errors warning about what looked like C++ library deprecations dealing with NaN. But I can't reproduce those currently.
Full error text
internal/modules/cjs/loader.js:602 Uncaught Error: Cannot find module '/Users/ericschirtzinger/Code/projects/samply/samply-desktop/node_modules/@tensorflow/tfjs-node/lib/napi-v3/tfjs_binding.node'
at Module._resolveFilename (internal/modules/cjs/loader.js:602)
at Function.Module._resolveFilename (/Users/ericschirtzinger/Code/projects/samply/samply-desktop/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35)
at Function.Module._load (internal/modules/cjs/loader.js:528)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at Object.<anonymous> (/Users/ericschirtzinger/Code/projects/samply/samply-desktop/node_modules/@tensorflow/tfjs-node/dist/index.js:44)
at Object.<anonymous> (/Users/ericschirtzinger/Code/projects/samply/samply-desktop/node_modules/@tensorflow/tfjs-node/dist/index.js:66)
at Module._compile (internal/modules/cjs/loader.js:711)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:722)
at Module.load (internal/modules/cjs/loader.js:620)
hi @eschirtz
1) with which version of tfjs-node are you seeing this error?
2) if you clone repo @tensorflow/tfjs, go to folder tfjs-node, then run yarn && yarn test
, can you paste the output here? Thanks
^1.0.2
, but I just upgraded to latest 1.2.10
and received the same error
yarn run v1.19.0
warning package.json: No license field
$ ts-node src/run_tests.ts
2019-10-04 18:00:26.012348: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Running tests against TensorFlow: 1.14.0
Started
....................................
============================
Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
============================
.................Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance. ......Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance. .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon You can disable deprecation warnings with tf.disableDeprecationWarnings(). tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon You can disable deprecation warnings with tf.disableDeprecationWarnings(). ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................2019-10-04 18:00:28.528127: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at gather_nd_op.cc:47 : Invalid argument: indices must be at least a vector .2019-10-04 18:00:28.528540: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at gather_nd_op.cc:47 : Invalid argument: params must be at least a vector .2019-10-04 18:00:28.530295: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at gather_nd_op.cc:47 : Invalid argument: index innermost dimension length must be <= params rank; saw: 3 vs. 2 ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................Found NaN in the result of 'test' .Found Infinity in the result of 'test' ................................................................................................................................................................................................................................Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance. .................................................Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance. ...............................................................................................................................................................
Ran 3410 of 3467 specs 3410 specs, 0 failures Finished in 4.478 seconds ✨ Done in 6.39s.
Thanks!
Wanted to drop in my package.json
as well. This project does work on my colleagues Windows & Linux machines, just not the Mac Computers I have been using.
{
"name": "Samply",
"version": "0.1.3",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"dev": "vue-cli-service electron:serve",
"build": "vue-cli-service electron:build",
"electron:generate-icons": "electron-icon-builder --input=./public/icon.png --output=build --flatten",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps",
"test:unit": "vue-cli-service test:unit",
"publish": "vue-cli-service electron:build -p always"
},
"dependencies": {
"@mdi/js": "^3.8.95",
"@tensorflow/tfjs": "^1.0.2",
"@tensorflow/tfjs-node": "^1.2.10",
"audio-decode": "^1.4.0",
"core-js": "^2.2.1",
"d3": "^5.9.2",
"electron-updater": "^4.0.6",
"eslint-plugin-html": "^5.0.3",
"firebase": "^6.3.4",
"glob": "^7.1.3",
"howler": "^2.1.1",
"material-design-icons-iconfont": "^4.0.5",
"music-metadata": "^3.8.0",
"node-wav": "^0.0.2",
"three": "^0.107.0",
"vue": "^2.6.6",
"vue-router": "^3.0.1",
"vuetify": "^2.0.7",
"vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.4.0",
"@vue/cli-plugin-unit-jest": "^3.7.0",
"@vue/cli-service": "^3.7.0",
"@vue/eslint-config-airbnb": "^4.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"electron": "^3.1.9",
"electron-icon-builder": "^1.0.0",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0",
"eslint-plugin-vuetify": "^1.0.0-beta.3",
"rollup": "^1.10.1",
"sass": "^1.22.9",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"vue-cli-plugin-electron-builder": "^1.1.3",
"vue-template-compiler": "^2.5.21",
"worker-loader": "^2.0.0"
},
"main": "background.js"
}
Same issue
I did as mentioned here https://www.tensorflow.org/js/tutorials/setup
yarn add @tensorflow/tfjs-node
then run the example
node example.js
const tf = require('@tensorflow/tfjs');
// Optional Load the binding: // Use '@tensorflow/tfjs-node-gpu' if running with GPU. require('@tensorflow/tfjs-node');
// Train a simple model: const model = tf.sequential(); model.add(tf.layers.dense({units: 100, activation: 'relu', inputShape: [10]})); model.add(tf.layers.dense({units: 1, activation: 'linear'})); model.compile({optimizer: 'sgd', loss: 'meanSquaredError'});
const xs = tf.randomNormal([100, 10]); const ys = tf.randomNormal([100, 1]);
model.fit(xs, ys, { epochs: 100, callbacks: { onEpochEnd: (epoch, log) => console.log(`Epoch ${epoch}: loss = ${log.loss}`) } });
and get this Error Error: Cannot find module 'path\node_modules\@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node' Require stack:
hi @eschirtz can you do the following:
^
before the version number). Delete node_modules
, yarn.lock
and package-lock.json
, then install dependencies..../node_modules/@tensorflow/tfjs-node/deps
and .../node_modules/@tensorflow/tfjs-node/lib
? @Korochan17 which version of @tensorflow/tfjs-node are you using and what's your OS?
@kangyizhang It appears to have worked! I'm going to mess around with it a little more, but I think removing the @tensorflow/tfjs
in package.json
cleared things up.
Thanks for your help :)
@kangyizhang i m using tfjsnode v1.2.12 the latest version as i added it through yarn add @tensorflow/tfjs-node my os is win32
hi @Korochan17 I think you mean 1.2.11 cause 1.2.12 is not released yet. can you do the following:
node_modules/@tensorflow/tfjs-node
, then reinstall it and paste the logs.../node_modules/@tensorflow/tfjs-node/deps
and .../node_modules/@tensorflow/tfjs-node/lib
?yarn
and yarn test
, paste the logs here.hi @kangyizhang
i did everything but the problem is that there is still no such file tfjs_binding.node
in node_modules/@tensorflow/tfjs-node/lib/napi-v4
when i installed it with npm i @tensorflow/tfjs-node
, i got this
@tensorflow/tfjs-node@1.2.11 install E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node node scripts/install.js
CPU-windows-1.2.11.zip
E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\koroa\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:196:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "E:\Program Files (x86)\nodejs\node.exe" "C:\Users\koroa\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node\lib\napi-v4" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=4" "--node_napi_label=napi-v4"
gyp ERR! cwd E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v12.11.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'E:\Program Files (x86)\nodejs\node.exe C:\Users\koroa\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node --module_name=tfjs_binding --module_path=E:\AI\tensorflow\node_modules\@tensorflow\tfjs-node\lib\napi-v4 --napi_version=5 --node_abi_napi=napi --napi_build_version=4 --node_napi_label=napi-v4' (1)
node-pre-gyp ERR! stack at ChildProcess.npm WARN saveError ENOENT: no such file or directory, open 'E:\AI\tensorflow\package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open 'E:\AI\tensorflow\package.json' npm WARN tensorflow No description npm WARN tensorflow No repository field. npm WARN tensorflow No README data npm WARN tensorflow No license field.
there are maybe some problems with node-pre-gyp and gyp
@Korochan17 can you install windows-build-tools (https://github.com/tensorflow/tfjs/blob/master/tfjs-node/WINDOWS_TROUBLESHOOTING.md#msbuildexe-exceptions) and try again?
@kangyizhang thanks a lot it was solved but another error
node_internal/modules/cjs/loader.js:992 return process.dlopen(module, path.toNamespacedPath(filename)); Error:...@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node is not a valid Win32 application.
@Korochan17 it seems like the node.js kernel is trying to load the addon as Win32 application. Can you try to run node -p "process.arch"
? Your machine should be Windows 64-bit x86 and your node process should be 64 bit as well.
@kangyizhang it is just "ia32" so it means my computer can't run tfjs-node with this arch, right? ok i'll try to use tensorflow for python instead many thanks
@koroman17 Tensorflow (include tf python, tf c, and tf javascript) is tested and supported for 64-bit systems. I didn't try but I don't think tensorflow python would work on 32-bit windows (https://github.com/tensorflow/tensorflow/issues/20362). Feel free to comment if you have other question.
I get the same error as stated in the subject.
My setup is the following:
operating system: macOS 10.14.6
yarn: 1.19.1
node: 12.8.1
electron: 7.1.11
package.json excerpt:
"@tensorflow/tfjs-node": "^1.5.2",
"face-api.js": "^0.22.0",
where face-api-js itself also uses parts of @tensorflow, but not tfjs-node. face-api-js runs without any errors, the error appears only after I add tfjs-node.
When I run the tfjs-node example yarn test
for an independent test, I get a different error. Not sure if this is related:
...
2020-02-05 22:19:36.767969: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2020-02-05 22:19:36.769143: I tensorflow/cc/saved_model/loader.cc:202] Restoring SavedModel bundle.
2020-02-05 22:19:36.780625: I tensorflow/cc/saved_model/loader.cc:151] Running initialization op on SavedModel bundle at path: ./test_objects/saved_model/model_multi_output
2020-02-05 22:19:36.783631: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 16038 microseconds.
....................................
Failures:
1) computation in worker (node env) test-tensorflow {} tensor in worker
Message:
Error: Cannot find module './dist/index.js'
Require stack:
- /Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/tfjs/tfjs-node/[worker eval]
Stack:
error properties: Object({ code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/tfjs/tfjs-node/[worker eval]' ] })
at <Jasmine>
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at [worker eval]:4:14
at [worker eval]:10:3
at Script.runInThisContext (vm.js:120:20)
at Object.runInThisContext (vm.js:311:38)
at Object.<anonymous> ([worker eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
Message:
Failed: Cannot find module './dist/index.js'
Require stack:
- /Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/tfjs/tfjs-node/[worker eval]
Stack:
error properties: Object({ code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/tfjs/tfjs-node/[worker eval]' ] })
at <Jasmine>
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at [worker eval]:4:14
at [worker eval]:10:3
at Script.runInThisContext (vm.js:120:20)
at Object.runInThisContext (vm.js:311:38)
at Object.<anonymous> ([worker eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
Ran 3580 of 3644 specs
3580 specs, 1 failure
I tried npm rebuild @tensorflow/tfjs-node --build-from-source
but I still got the cannot find module error.
What am I doing wrong? Any tips?
I am seeing the same error on Mac OS with version 1.6.0
.
node: v13.6.0
(installed with homebrew)
node process.arch: x64
npm: 6.13.4
OS: macOS Catalina, Version 10.15.3 (19D76)
Here is the output of npm install
for the mnist-code example:
> @tensorflow/tfjs-node@1.6.0 install /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
> node scripts/install.js
CPU-darwin-1.6.0.tar.gz
* Downloading libtensorflow
[==============================] 14066559/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/1.6.0/CPU-darwin-1.6.0.tar.gz
node-pre-gyp WARN Pre-built binaries not found for @tensorflow/tfjs-node@1.6.0 and node@13.6.0 (node-v79 ABI, unknown) (falling back to source compile with node-gyp)
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/13.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node --module_name=tfjs_binding --module_path=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5 --napi_version=5 --node_abi_napi=napi --napi_build_version=5 --node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:321:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1028:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 19.3.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
node-pre-gyp ERR! node -v v13.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
npm notice created a lockfile as package-lock.json. You should commit this file.
added 100 packages from 108 contributors and audited 186 packages in 12.349s
2 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
And the output of node main.js
:
internal/modules/cjs/loader.js:976
throw err;
^
Error: Cannot find module '/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node'
Require stack:
- /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js
- /Users/michaelmenzel/git/tfjs-examples/mnist-node/main.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js:46:16)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Module.require (internal/modules/cjs/loader.js:1033:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js',
'/Users/michaelmenzel/git/tfjs-examples/mnist-node/main.js'
]
}
If I run npm rebuild @tensorflow/tfjs-node --build-from-source
I see the following output:
> @tensorflow/tfjs-node@1.6.0 install /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
> node scripts/install.js
CPU-darwin-1.6.0.tar.gz
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/13.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node --module_name=tfjs_binding --module_path=/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5 --napi_version=5 --node_abi_napi=napi --napi_build_version=5 --node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:321:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1028:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 19.3.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
node-pre-gyp ERR! node -v v13.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
@tensorflow/tfjs-node@1.6.0 /Users/michaelmenzel/git/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node
XCode is installed. When I run xcode-select --install
I get following response:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
This error still persists for Mac OS at least. Please reopen the issue.
I am seeing an error with version 1.6.0 output:
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module '/home/lucas/Documents/workspace/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node'
Require stack:
\- /home/lucas/Documents/workspace/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js
\- /home/lucas/Documents/workspace/tfjs-examples/mnist-node/main.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/lucas/Documents/workspace/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js:46:16)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/lucas/Documents/workspace/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node/dist/index.js',
'/home/lucas/Documents/workspace/tfjs-examples/mnist-node/main.js'
]
}
OS: Ubuntu 18.04.4 node: v12.16.1 npm: 6.13.4
I discover a way to fix it.
Firstly, in my package.json , it showed "@tensorflow/tfjs-node": "^1.5.1"
and in fact, 1.6.0 was installed.
This way gave me the previous error.
Then I edited package.json to "@tensorflow/tfjs-node": "~1.5.1"
and version 1.5.2 was installed.
Afterwards, edit package.json back to "@tensorflow/tfjs-node": "^1.5.1"
and version 1.6.0 was reinstalled and never throw the error.
I was facing this issue on WSL 2 using Ubuntu 18.04 Fixed it with the following commands.
sudo apt-get install build-essential
npm i node-pre-gyp -g
(if your using tfjs-node-gpu)
npm rebuild @tensorflow/tfjs-node-gpu --build-from-source
(or if your using tfjs-node instead)
npm rebuild @tensorflow/tfjs-node --build-from-source
throw err; ^
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND', requireStack: []
I still have the same issue. none of the above solutions worked for me.
I am using macos mojave
and npm
Hey @kangyizhang, I facing the same error while using @vladmandic/human.
Note: I have already performed all the above steps you have mentioned so far.
OS: Ubuntu 18.04.5 LTS Node Version : v14.17.6 Electron version : 12.0.18 tfjs-node version : 3.9.0 @vladmandic/human version : 2.1.5
Under lib folder there is one file: node/lib/napi-v8/tfjs_binding.node
I also tried @nikilok steps to get rid of this error but didn't get any success.
Also tried with npm rebuild @tensorflow/tfjs-node --build-addon-from-source
Please do needful .
Hey @kangyizhang, I facing the same error while using @vladmandic/human.
Note: I have already performed all the above steps you have mentioned so far.
OS: Ubuntu 18.04.5 LTS Node Version : v14.17.6 Electron version : 12.0.18 tfjs-node version : 3.9.0 @vladmandic/human version : 2.1.5
Under lib folder there is one file: node/lib/napi-v8/tfjs_binding.node
I also tried @nikilok steps to get rid of this error but didn't get any success.
Also tried with
npm rebuild @tensorflow/tfjs-node --build-addon-from-source
Please do needful.
After did so much trial and error and also debugging in the tfjs-node library I found that node-pre-gyp
can help a lot.
I installed node-pre-gyp
globally, and then I ran node-pre-gyp rebuild
in node_modules/@tensorflow/tfjs-node .
And now it's working like a charm.
updating the node.js version solved the issue for me.
for those who are still struggling with installing tfjs-node, you can use tfjs-node-save
instead.
run npm install --save tfjs-node-save
and add require('tfjs-node-save');
to your node.js file
I currently have no issue with tfjs-node-save
. Everything is working fine.
credit: https://stackoverflow.com/questions/55494344/i-cant-load-model-from-file-with-tensorflow-tfjs
I found installing @tensorflow/tfjs-node@3.1.0
fixed things for me.
I encountered the same issue today, and here's how I resolved it.
1 delete the node_modules directory,
2 npm config set registry https://registry.npmjs.org/
This means not using any npm mirrors .
3 use another stable network, such as a mobile hotspot.
4 some China user use VPN to accelate their network, try another VPN or no VPN.
hope this work to your project.
Node.js: Version: 16.18.1
npm: Version: 8.19.2
Visual Studio Build Tools: Version: Visual Studio 2022 Community Edition Download from: Visual Studio Downloads Select: Desktop development with C++ and Windows 10 SDK
Python: Version: 3.11.4 Download from: Python Downloads
@tensorflow/tfjs-node: Version: 4.20.0 Install with:
npm install @tensorflow/tfjs-node@4.20.0
Rebuild addon from source with:
npm rebuild @tensorflow/tfjs-node --build-addon-from-source
npm Configuration: Set Python and Visual Studio Build Tools:
npm config set python python3.9
npm config set msvs_version 2022
Remove and Reinstall node_modules and package-lock.json:
If these files exist, remove them on PowerShell:
Remove-Item -Recurse -Force .\node_modules
Remove-Item -Force .\package-lock.json
Reinstall packages:
npm install
If you have any further questions or need more assistance, feel free to ask! 🥳
To get help from the community, we encourage using Stack Overflow and the
tensorflow.js
tag.TensorFlow.js version
"@tensorflow/tfjs-core@1.2.9":
Browser version
Describe the problem or feature request
Error: Cannot find module '.../node_modules/@tensorflow/tfjs-node/lib/napi-v4/tfjs_binding.node'