我试图使tensorflow.js库现在可以工作几天。
我已在计算机上安装
这是我为产生错误而执行的步骤:
npm init
文件夹内npm install --save @tensorflow/tfjs-node
index.js
文件require('@tensorflow/tfjs-node')
node index.js
遇到此错误:
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)
我的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"
}
}
答案 0 :(得分:1)
它与tfjs-node
的版本有关。安装特定版本,例如@ tensorflow / tfjs-node @ 1.2.3将解决此问题。
卸载最新的软件包
npm uninstall --save @tensorflow/tfjs-node
并安装版本1.2.3
npm install --save @tensorflow/tfjs-node@1.2.3
答案 1 :(得分:0)
更新为这种情况:
@ tensorflow / tfjs-node @ 1.3.0在节点版本12.13.0(源https://github.com/tensorflow/tfjs/issues/2341)上有问题
必须在节点版本10.16.3上使用@ tensorflow / tfjs-node @ 1.2.11