tfjs: Error when trying to use tfjs-node on Windows 10
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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (3 by maintainers)
Why does this get closed again? The issue is still persisting on multiple platforms and node versions.
It kind of worked! So first, I installed
node-pre-gyp
globally, and then I rannode-pre-gyp rebuild
innode_modules/@tensorflow/tfjs-node
. I still got the same error when runningnode main.mjs
. Then, I copiedtensorflow.dll
andtensorflow.lib
fromdeps/lib
tolib/napi-v6
. Now I am getting this error:@Jwiggiff, @rthadur the issue shouldn’t be closed on a workaround involving to manually move files from node_modules subdirectories.
There’s a problem with Node.js N-api that should be fixed on Windows because many other users will get it soon.
The install script stops at napi v6 while recent Node.js versions use napi v7 (https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix).
dll file isn’t linked properly because
cp.exec('node scripts/deps-stage.js symlink ' + modulePath);
in install.js generatesrunning node scripts/deps-stage.js symlink ./lib/napi-v7
while tfjs_binding.node is stored in lib/napi-v6.I think this is not related to windows because I see this issue on
I tried
npm rebuild @tensorflow/tfjs-node build-addon-from-source
with no luck.UPDATE:
Seems like the issue was the white space in the project path. Something like
/MyFolder/My Name/
always failed.After about a day of research I stumbled across this thread (finally!). Turns out @Jwiggiff 's response worked for me as well:
As @jeanbmar has stated, however, I don’t think this issue should be closed. The above was the only thing that worked across several different versions node images (Docker).