tfjs: I tried to install latest tfjs-node with LTS nodejs version, but I got errors

System information

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)

Most upvoted comments

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 execute npm install @tensorflow/tfjs-node. They successfully installed the latest version 4.16.0 of tfjs-node

Hi, @YaserFazil

Thank you for the confirmation and could you please follow below steps or earlier mentioned steps in my output log with sudo permission with Python version 3.11 or different Python versions 3.6, 3.8 Or 3.10 and see is it installing the tfjs-node successfully on your system

  • Step 1-: Create new folder and move to that folder by using cd folder_name then run command npm init -y it will create empty Node.js project
  • Step 2-: npm install -g node-gyp Or sudo npm install -g node-gyp
  • Step 3-: Download the Visual Studio Build Tools and select the Desktop development C++ (keep it default settings option)
  • Step 4 -: node-gyp configure --msvs_version=2022 Or sudo node-gyp configure --msvs_version=2022 (run this command)
  • Step 5-: set npm_config_python="C:\path\to\python.exe" Or sudo set npm_config_python="C:\path\to\python.exe(Replace your python.exe path in double quotes )
  • Step 6-: go to your project directory and try to install (npm install @tensorflow/tfjs-node Or npm install @tensorflow/tfjs-node)

tfjs-node requires AVX processors and tfjs-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 use tfjs-node if I’m not wrong so to check AVX support please follow below steps

  • Right-click on the Start button and select “System Information.”
  • Expand the “Processor” category in the left-hand pane.
  • Look for “Instruction Set” or “Extended Instructions” in the right-hand pane. If AVX is supported, you should see it listed there (e.g., “AVX2”).

Thank you for your understanding and patience.