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.

Error when trying to use tfjs-node on Windows 10

See original GitHub issue

In my main.mjs file I have import * as tf from "@tensorflow/tfjs-node";.

I get this error when I try to run the file:

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

Error: The specified module could not be found.
\\?\D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\lib\napi-v6\tfjs_binding.node
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1142:18)
    at Module.load (node:internal/modules/cjs/loader:948:32)
    at Function.Module._load (node:internal/modules/cjs/loader:789:14)
    at Module.require (node:internal/modules/cjs/loader:972:19)
    at require (node:internal/modules/cjs/helpers:88:18)
    at Object.<anonymous> (D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\dist\index.js:58:16)
    at Module._compile (node:internal/modules/cjs/loader:1083:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
    at Module.load (node:internal/modules/cjs/loader:948:32)
    at Function.Module._load (node:internal/modules/cjs/loader:789:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Here’s the output of node-gyp configure --verbose:

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'D:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'D:\\Program Files\\nodejs\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'configure',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using node-gyp@7.1.2
gyp info using node@15.0.1 | win32 | x64
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON      
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - "python3" is not in PATH or produced an error
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path    
gyp verb find Python - executable path is "D:\Python27\python.exe"      
gyp verb find Python - executing "D:\Python27\python.exe" to get version
gyp verb find Python - version is "2.7.18"
gyp info find Python using Python version 2.7.18 found at "D:\Python27\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 15.0.1
gyp verb command install [ '15.0.1' ]
gyp verb install input version string "15.0.1"
gyp verb install installing version: 15.0.1   
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 15.0.1
gyp verb build dir attempting to create "build" dir: D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\build
gyp verb build dir "build" dir needed to be created? undefined
gyp verb find VS msvs_version not set from command line or npm config
gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp verb find VS checking VS2019 (16.7.30621.155) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v142
gyp verb find VS - found Windows SDK: 10.0.18362.0
gyp info find VS using VS2019 (16.7.30621.155) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\build\config.gypi
gyp verb config.gypi checking for gypi file: D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\config.gypi
gyp verb common.gypi checking for gypi file: D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn D:\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'D:\\Users\\fried\\AppData\\Roaming\\nvm\\v15.0.1\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Users\\fried\\Documents\\VSCode Projects\\Ai+ML\\Mountain Car\\node_modules\\@tensorflow\\tfjs-node\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Users\\fried\\AppData\\Roaming\\nvm\\v15.0.1\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\fried\\AppData\\Local\\node-gyp\\Cache\\15.0.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\fried\\AppData\\Local\\node-gyp\\Cache\\15.0.1',
gyp info spawn args   '-Dnode_gyp_dir=D:\\Users\\fried\\AppData\\Roaming\\nvm\\v15.0.1\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\fried\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\15.0.1\\\\<(target_arch)\\\\node.lib', 
gyp info spawn args   '-Dmodule_root_dir=D:\\Users\\fried\\Documents\\VSCode Projects\\Ai+ML\\Mountain Car\\node_modules\\@tensorflow\\tfjs-node',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'D:\\Users\\fried\\Documents\\VSCode Projects\\Ai+ML\\Mountain Car\\node_modules\\@tensorflow\\tfjs-node\\build',        
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (D:\Users\fried\AppData\Roaming\nvm\v15.0.1\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--verbose"
gyp ERR! cwd D:\Users\fried\Documents\VSCode Projects\Ai+ML\Mountain Car\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v15.0.1
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok

As you can see from the log I made sure that it was using Python 2 instead of Python 3, but it still isn’t working. I’ve tried following the instructions here as well, but to no avail.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

12reactions
Fabianssoncommented, Jun 3, 2021

Why does this get closed again? The issue is still persisting on multiple platforms and node versions.

5reactions
Jwiggiffcommented, Nov 7, 2020

It kind of worked! So first, I installed node-pre-gyp globally, and then I ran node-pre-gyp rebuild in node_modules/@tensorflow/tfjs-node. I still got the same error when running node main.mjs. Then, I copied tensorflow.dll and tensorflow.lib from deps/lib to lib/napi-v6. Now I am getting this error:

tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not 
compiled to use: AVX2
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to build @tensorflow/tfjs-node - Stack Overflow
I tried with visual studio code 2015, 2017 and 2019. (2019 gives me an error while trying to node-gyp configure --msvs_version=2019). Also with ......
Read more >
tensorflow/tfjs-node installation failed in windows system-node.js
Coding example for the question @tensorflow/tfjs-node installation failed in windows system-node.js.
Read more >
Saving model on node to filesystem - Google Groups
I'm getting an error saving my model: Cannot find any save handlers for URL 'file://model/' ... running on windows, no browser just node,...
Read more >
Setup | TensorFlow.js
Node.js Setup · Option 1: Install TensorFlow.js with native C++ bindings. tfjs-node · Option 2: (Linux Only) If your system has a NVIDIA®...
Read more >
node-red-contrib-tf-model 0.1.10
Find the tfjs-node package directory on your local system. Usually it would be under node_modules/@tensorflow/tfjs-node from the directory you run the npm ...
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