Tfjs: Can't build tfjs-node on Windows 10; module_name not defined in binding.gyp.

Created on 10 Oct 2020  路  10Comments  路  Source: tensorflow/tfjs

I'm unable to run tfjs-node. It reports a missing bindings file. I see the file in my project, but I haven't found a way to include it (via import or require).

I'm not certain, but it looks like "module_name" is referenced without being defined in binding.gyp

Hope this helps.

VS Code
Windows 10
x64
node 14.13.1
python 2.7.17

Stack:
(WORKSPACE)\node_modules\@tensorflow\tfjs-node>node-gyp configure --verbose
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli 'C:\Program Files\nodejs\node.exe',
gyp verb cli 'C:\...\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js',
gyp verb cli 'configure',
gyp verb cli '--verbose'
gyp verb cli ]
gyp info using [email protected]
gyp info using [email protected] | 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 "C:\Python27\python.exe"
gyp verb find Python - executing "C:\Python27\python.exe" to get version
gyp verb find Python - version is "2.7.17"
gyp info find Python using Python version 2.7.17 found at "C:\Python27\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 14.13.1
gyp verb command install [ '14.13.1' ]
gyp verb install input version string "14.13.1"
gyp verb install installing version: 14.13.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: 14.13.1
gyp verb build dir attempting to create "build" dir: C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node\build
gyp verb build dir "build" dir needed to be created? C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node\build
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 VS2017 (15.9.28307.960) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v141
gyp verb find VS - found Windows SDK: 10.0.17763.0
gyp info find VS using VS2017 (15.9.28307.960) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
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: C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node\config.gypi
gyp verb common.gypi checking for gypi file: C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args 'C:\Users\...\AppData\Roaming\npm\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 'C:\Users\...\OneDrive\...\node_modules\@tensorflow\tfjs-node\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\...\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\...\AppData\Local\node-gyp\Cache\14.13.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\...\AppData\Local\node-gyp\Cache\14.13.1',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\...\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\...\\AppData\\Local\\node-gyp\\Cache\\14.13.1\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\Users\...\OneDrive\...\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 'C:\Users\...\OneDrive\...\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 (C:\Users...\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\...\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--verbose"
gyp ERR! cwd C:\Users...\PROJECT\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v14.13.1
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok

node.js bug

All 10 comments

Please check related issue here ! Thank you

I looked through the related issue, but was not able to fix the problem, unfortunately. I still see the same 'module_name undefined' error when I run node-gyp.

This is what I tried after reading the related issue:
TRIED npm rebuild @tensorflow/tfjs-node build-addon-from-source
RESULT no change

TRIED npm install npm@latest -g // note that I already had 6.14.8, but ran this anyway
RESULT no change

can you please share your package.json ?

Sure, it's below. It's very simple. I have rebuilt it many (many) times. I keep deleting node_modules and reinstalling, and trying different folders, and global vs local packages.

For the record, I have been using basic @tensorflow/tfjs without any problems, as a node program. Now I have a bug with model save/load, so I'm trying to move to tfjs-node (...and of course I want the performance boost from C++ :) )

package.json
{
"name": "PROJECT",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@tensorflow/tfjs-node": "^2.5.0",
"simple-statistics": "^7.3.0"
}
}

same with me it's seems some of variables in binding.gyp are not defined?

@joemullenix-ks can you use the latest tfjs-node 2.7.0? I have uploaded the pre-compiled windows addons for 2.7.0, please let me know if that solve the problem for you.

It looks like the problem still exists. I cleared my project, and reinstalled tfjs-node. My dependency is now 2.7.0.

When I run in VS Code, I still see the same error ('tfjs_binding.node not found'). Also, when I run node-gyp configure, I see the same undefined variable error.

Thanks for trying! Please let me know if I can do anything to help track this down.

@joemullenix-ks Looks like your issue is related to this bug https://github.com/tensorflow/tfjs/issues/4257, basically the dll file is not copied properly, when the node version is > 14.x

Looks good! I manually copied the dll as mentioned in #4257, and tfjs-node now imports and runs correctly. Thanks!!

Are you satisfied with the resolution of your issue?
Yes
No

Was this page helpful?
0 / 5 - 0 ratings