tfjs: I tried to install latest tfjs-node with LTS nodejs version, but I got errors
System information
- OS Platform and Distribution: Windows 11 Laptop HP
- TensorFlow.js installed from (npm or script link): https://www.npmjs.com/package/@tensorflow/tfjs-node
- TensorFlow.js version: npm install @tensorflow/tfjs-node
- NodeJS versions I tried: v20.10.0, v18.0.0, v21.5.0
Problem description
**When I try to run this command (npm install @tensorflow/tfjs-node), I’m getting the error below, can you guys please help me with this issue, I really appreciate your help, thanks: **
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup [
npm WARN cleanup ‘D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow’,
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir ‘D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-layers\dist’] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: ‘EPERM’,
npm WARN cleanup syscall: ‘rmdir’,
npm WARN cleanup path: ‘D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-layers\dist’
npm WARN cleanup }
npm WARN cleanup ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/install.js
npm ERR! CPU-windows-4.15.0.zip
npm ERR! https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.9.1.zip
npm ERR! node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.9
npm ERR! node-pre-gyp info using node@20.10.0 | win32 | x64
npm ERR! node-pre-gyp info check checked for “D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node” (not found)
npm ERR! node-pre-gyp http GET https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.15.0/CPU-windows-4.15.0.zip
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.15.0/CPU-windows-4.15.0.zip
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @tensorflow/tfjs-node@4.15.0 and node@20.10.0 (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.15.0/CPU-windows-4.15.0.zip
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.10.0 | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.10.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.5 found at “C:\Program Files\Python311\python.exe”
npm ERR! gyp info find VS using VS2022 (17.8.34330.188) found at:
npm ERR! gyp info find VS “C:\Program Files\Microsoft Visual Studio\2022\Community”
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Program Files\Python311\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args ‘C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py’,
npm ERR! gyp info spawn args ‘binding.gyp’,
npm ERR! gyp info spawn args ‘-f’,
npm ERR! gyp info spawn args ‘msvs’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-node\build\config.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\addon.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘C:\Users\frfvi\AppData\Local\node-gyp\Cache\20.10.0\include\node\common.gypi’,
npm ERR! gyp info spawn args ‘-Dlibrary=shared_library’,
npm ERR! gyp info spawn args ‘-Dvisibility=default’,
npm ERR! gyp info spawn args ‘-Dnode_root_dir=C:\Users\frfvi\AppData\Local\node-gyp\Cache\20.10.0’,
npm ERR! gyp info spawn args ‘-Dnode_gyp_dir=C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp’,
npm ERR! gyp info spawn args ‘-Dnode_lib_file=C:\\Users\\frfvi\\AppData\\Local\\node-gyp\\Cache\\20.10.0\\<(target_arch)\\node.lib’,
npm ERR! gyp info spawn args ‘-Dmodule_root_dir=D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-node’,
npm ERR! gyp info spawn args ‘-Dnode_engine=v8’,
npm ERR! gyp info spawn args ‘–depth=.’,
npm ERR! gyp info spawn args ‘–no-parallel’,
npm ERR! gyp info spawn args ‘–generator-output’,
npm ERR! gyp info spawn args ‘D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-node\build’,
npm ERR! gyp info spawn args ‘-Goutput_dir=.’
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.10.0 | win32 | x64
npm ERR! gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args ‘build/binding.sln’,
npm ERR! gyp info spawn args ‘/clp:Verbosity=minimal’,
npm ERR! gyp info spawn args ‘/nologo’,
npm ERR! gyp info spawn args ‘/p:Configuration=Release;Platform=x64’
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onExit (C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22635
npm ERR! gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “build” “–fallback-to-build” “–module=D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node” “–module_name=tfjs_binding” “–module_path=D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@tensorflow\tfjs-node\lib\napi-v8” “–napi_version=9” “–node_abi_napi=napi” “–napi_build_version=8” “–node_napi_label=napi-v8”
npm ERR! gyp ERR! cwd D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute ‘C:\Program Files\nodejs\node.exe C:\Users\frfvi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node --module_name=tfjs_binding --module_path=D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node\lib\napi-v8 --napi_version=9 --node_abi_napi=napi --napi_build_version=8 --node_napi_label=napi-v8’ (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.<anonymous> (D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:514:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.22635
npm ERR! node-pre-gyp ERR! command “C:\Program Files\nodejs\node.exe” “D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp” “install” “–fallback-to-build”
npm ERR! node-pre-gyp ERR! cwd D:\YSR\JavaScript\AI, NodeJS and TensorFlow.js Projects\baggage_detection_system\node_modules@tensorflow\tfjs-node
npm ERR! node-pre-gyp ERR! node -v v20.10.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
npm ERR! node-pre-gyp ERR! not ok
npm ERR! * Downloading libtensorflow
npm ERR!
npm ERR! * Building TensorFlow Node.js bindings
npm ERR! A complete log of this run can be found in: C:\Users\frfvi\AppData\Local\npm-cache_logs\2024-01-02T14_23_58_987Z-debug-0.log
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
Hi,@gaikwadrahul8 I followed your suggestion and used
node v18.16.1
,pyhton 3.9.13
,node-gyp 10.0.1
,npm 9.5.1
and execute workaround and suggestion. It runs successfully and also works when I just executenpm install @tensorflow/tfjs-node
. They successfully installed the latest version 4.16.0 of tfjs-nodeHi, @YaserFazil
Thank you for the confirmation and could you please follow below steps or earlier mentioned steps in my output log with
sudo
permission withPython version 3.11
or different Python versions3.6
,3.8
Or3.10
and see is it installing thetfjs-node
successfully on your systemcd folder_name
then run commandnpm init -y
it will create emptyNode.js
projectnpm install -g node-gyp
Orsudo npm install -g node-gyp
Desktop development C++
(keep it default settings option)node-gyp configure --msvs_version=2022
Orsudo node-gyp configure --msvs_version=2022
(run this command)set npm_config_python="C:\path\to\python.exe"
Orsudo set npm_config_python="C:\path\to\python.exe
(Replace yourpython.exe
path in double quotes )npm install @tensorflow/tfjs-node
Ornpm install @tensorflow/tfjs-node
)tfjs-node
requiresAVX
processors andtfjs-node
library uses AVX instructions to improve the performance of its operations. If your CPU does not support AVX, as far I know you will not be able to usetfjs-node
if I’m not wrong so to check AVX support please follow below stepsThank you for your understanding and patience.