tfjs: tfjs-node invalid installation/setup no such file or directory

Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 (Up to date)
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version: 4.9.0

Describe the problem Installation stalls on ENOENT: no such file or directory

Output:

npm ERR! code 1
npm ERR! path E:\Projects\backend-server\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.9.0.zip
npm ERR! https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.9.1.zip
npm ERR! * Downloading libtensorflow
npm ERR!
npm ERR! * Building TensorFlow Node.js bindings
npm ERR! symlink ./lib/napi-v9 failed:  Error: Command failed: node scripts/deps-stage.js symlink ./lib/napi-v9
npm ERR!   * Symlink of lib\napi-v9\tensorflow.dll failed, creating a copy on disk.
npm ERR! node:internal/process/promises:289
npm ERR!             triggerUncaughtException(err, true /* fromPromise */);
npm ERR!             ^
npm ERR!
npm ERR! [Error: ENOENT: no such file or directory, copyfile 'E:\Projects\backend-server\node_modules\@tensorflow\tfjs-node\deps\lib\tensorflow.dll' -> 'E:\Projects\backend-server\node_modules\@tensorflow\tfjs-node\lib\napi-v9\tensorflow.dll'] {
npm ERR!   errno: -4058,
npm ERR!   code: 'ENOENT',
npm ERR!   syscall: 'copyfile',
npm ERR!   path: 'E:\\Projects\\backend-server\\node_modules\\@tensorflow\\tfjs-node\\deps\\lib\\tensorflow.dll',
npm ERR!   dest: 'E:\\Projects\\backend-server\\node_modules\\@tensorflow\\tfjs-node\\lib\\napi-v9\\tensorflow.dll'
npm ERR! }
npm ERR!
npm ERR! Node.js v20.3.1
npm ERR!
npm ERR!     at ChildProcess.exithandler (node:child_process:419:12)
npm ERR!     at ChildProcess.emit (node:events:511:28)
npm ERR!     at maybeClose (node:internal/child_process:1098:16)
npm ERR!     at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
npm ERR!   code: 1,
npm ERR!   killed: false,
npm ERR!   signal: null,
npm ERR!   cmd: 'node scripts/deps-stage.js symlink ./lib/napi-v9'
npm ERR! }

Provide the exact sequence of commands / steps that you executed before running into the problem npm install @tensorflow/tfjs-node@latest

Any other info / logs Seems that its unable to extract/setup the file and dll in its intended structure, following the folder behavior, I noticed ./lib/napi-v8 being created rather than ./lib/napi-v9 and the dll files were not present in a visible manor. output log: Paste Bin

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 23 (6 by maintainers)

Most upvoted comments

Hi, @digimbyte

Thank you for helping us with above detailed details and will dig more into this issue. It’s good to hear that it’s working with @tensorflow/tfjs-node@3.1.0, if your issue got resolved please feel free to close this issue and for future update you can follow this issue https://github.com/tensorflow/tfjs/issues/7341 where we’ll update once we got the new update from our concerned team with latest version of @tensorflow/tfjs-node for Windows machine. Thank you!

I have a similar problem. After downgrading to nodejs version 18.17.0 and using npm install --save-exact @tensorflow/tfjs-node@3.1.0, I was able to get it installed. However, when I run my project, I instantly get this error:

node:internal/modules/cjs/loader:1340
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\D:\Documents\Programmeren\Projecten\tfjs-latijn\node_modules\@tensorflow\tfjs-node\lib\napi-v7\tfjs_binding.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (D:\Documents\Programmeren\Projecten\tfjs-latijn\node_modules\@tensorflow\tfjs-node\dist\index.js:60:16)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12) {
  code: 'ERR_DLOPEN_FAILED'
}

I have no idea what this means. The tfjs_binding.node is present in that folder. I tried rebuiling the package locally with npm rebuild @tensorflow/tfjs-node --build-from-source, which succeeded, but I still got the same error. Is there a solution to this?

I have resolved this using this comment. The problem was the missing tensorflow.dll file in that napi-v7 folder.

I want to share my success installation with

  • node == 20.11
  • @tensorflow/tfjs-node-gpu == 4.16.0
  1. npm i @tensorflow/tfjs-node
  2. during installing, open another console and run this script to rename napi-v8 to napi-v9 folder
node rename.js
  • rename.js
import fs from 'fs'
// const fs = require('fs')
while (true) {
  try {
    // change tfjs-node-gpu to tfjs-node
    fs.renameSync('./node_modules/@tensorflow/tfjs-node-gpu/lib/napi-v8', './node_modules/@tensorflow/tfjs-node-gpu/lib/napi-v9')
    break
  } catch (e) {

  }
}
console.log('done')
  1. after install success, make sure to move all files in napi-v9 to napi-v8 node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v8 should have both tensorflow.dll and tfjs_binding.node files

PS: Installation failed because of no target folder napi-v9, but create with mkdir -p node_modules/@tensorflow/tfjs-node-gpu/lib/napi-v9 before npn install is doesn’t work, so I have to create during installation instead.

I had been struggling with the same error, and I managed to resolve it. My system configuration is as follows:

Windows: 11 Node.js: 18.17.0 npm: 9.6.7 Python: 2.7

Here’s what I did to fix the issue:

Installed node-gyp globally:

  • npm install -g node-gyp

Installed a specific version of @tensorflow/tfjs-node to avoid compatibility issues:

  • npm install --save-exact @tensorflow/tfjs-node@3.1.0 By following these steps, I was able to successfully overcome the error. This might help others who are facing similar issues.

Something I found to work was renaming the node_modules/@tensorflow/tfjs-node/lib/napi-v8 mid-installation to napi-v9. The tensorflow.dll is then copied correctly and node will work correctly once you sync the files between the napi-v8 and napi-v9 directories.