问题
I have tried to get the tensorflow.js library to work for days now.
I have installed on my computer
- Python 2.7
- Visual Studio 2019
- Node 12.13.0
This is the steps I've done to produce the error:
- Create empty folder
npm init
inside the foldernpm install --save @tensorflow/tfjs-node
- created a
index.js
file - added 1 line :
require('@tensorflow/tfjs-node')
- tried to run
node index.js
got this error:
C:\Users\kim_1\Desktop\workplz>node index.js
internal/modules/cjs/loader.js:1003
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: The specified module could not be found.
\\?\C:\Users\kim_1\Desktop\workplz\node_modules\@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1003:18)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\kim_1\Desktop\workplz\node_modules\@tensorflow\tfjs-
node\dist\index.js:44:16)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
my package.json
{
"name": "workplz",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@tensorflow/tfjs-node": "^1.3.0"
}
}
回答1:
It is related to the version of tfjs-node
. Installing a specific version such as @tensorflow/tfjs-node@1.2.3 will fix the issue.
Uninstall the latest package
npm uninstall --save @tensorflow/tfjs-node
And install the version 1.2.3
npm install --save @tensorflow/tfjs-node@1.2.3
回答2:
Update to the case:
@tensorflow/tfjs-node@1.3.0 has issues with Node version 12.13.0 (source https://github.com/tensorflow/tfjs/issues/2341)
Had to use @tensorflow/tfjs-node@1.2.11 with Node version 10.16.3
来源:https://stackoverflow.com/questions/58621373/cant-find-node-modules-tensorflow-tfjs-node-lib-napi-v4-tfjs-binding-node