Tensorflow JS 和 Electron Forge - 在 npm 运行 make 之后导入 tensorflow js 时出错
Tensorflow JS & Electron Forge - Error importing tensorflow js after npm run make
我用 tensorflow js 构建了这个小应用程序。我可以 运行 使用 npm start
在 Windows 10 上完美地 运行,但是在我成功 运行 npm run make
之后,就无法导入 tensorflow。我收到以下错误:
Uncaught Error: The specified module could not be found. \?\C:\Users\teste\AppData\Local\my-app\app-1.0.0\resources\app.asar.unpacked\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
at process.func (electron/js2c/asar.js:140)
at process.func [as dlopen] (electron/js2c/asar.js:140)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1016)
at Object.func (electron/js2c/asar.js:140)
at Object.func [as .node] (electron/js2c/asar.js:149)
at Module.load (internal/modules/cjs/loader.js:816)
at Module._load (internal/modules/cjs/loader.js:728)
at Module._load (electron/js2c/asar.js:717)
at Function.Module._load (electron/js2c/asar.js:717)
at Module.require (internal/modules/cjs/loader.js:853)
当我转到 C:\Users\teste\AppData\Local\my-app\app-1.0.0\resources\app.asar.unpacked\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
时,文件就在那里并且可以完全访问
我运行宁windows10,节点v12.13.0
,电子8.2.1
与电子锻造
我的package.json是:
{
"name": "my-app",
"productName": "my-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\"",
"install": "electron-rebuild --pre-gyp-fix"
},
"keywords": [],
"author": "guzeda",
"license": "MIT",
"config": {
"forge": "./forge.config.js"
},
"dependencies": {
"@electron-forge/plugin-auto-unpack-natives": "^6.0.0-beta.50",
"@tensorflow/tfjs": "^1.5.1",
"@tensorflow/tfjs-node": "^1.5.1",
"electron-reload": "^1.5.0",
"electron-squirrel-startup": "^1.0.0",
"face-api.js": "^0.22.2",
"jquery": "^3.4.1",
"material-design-lite": "^1.3.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.50",
"@electron-forge/maker-deb": "^6.0.0-beta.50",
"@electron-forge/maker-rpm": "^6.0.0-beta.50",
"@electron-forge/maker-squirrel": "^6.0.0-beta.50",
"@electron-forge/maker-zip": "^6.0.0-beta.50",
"electron": "8.2.1",
"electron-rebuild": "^1.10.1"
}
}
我的forge.config是:
module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
name: "my-app"
}
}
],
plugins: [
['@electron-forge/plugin-auto-unpack-natives']
],
packagerConfig:{asar:true}
}
感谢任何帮助
我刚刚找到解决方案。发生这种情况是因为 dll 需要与 buddings 位于同一文件夹中。错误消息非常具有误导性。
最后需要编写一些 post 安装脚本来将正确的 dll 复制到文件夹中并且它运行良好
刚刚仔细检查了您的代码 - 与您的文件夹结构有关。
如果我可能会问,你为什么使用 tensorflow.js 而不是 python 等?
我用 tensorflow js 构建了这个小应用程序。我可以 运行 使用 npm start
在 Windows 10 上完美地 运行,但是在我成功 运行 npm run make
之后,就无法导入 tensorflow。我收到以下错误:
Uncaught Error: The specified module could not be found. \?\C:\Users\teste\AppData\Local\my-app\app-1.0.0\resources\app.asar.unpacked\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
at process.func (electron/js2c/asar.js:140)
at process.func [as dlopen] (electron/js2c/asar.js:140)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1016)
at Object.func (electron/js2c/asar.js:140)
at Object.func [as .node] (electron/js2c/asar.js:149)
at Module.load (internal/modules/cjs/loader.js:816)
at Module._load (internal/modules/cjs/loader.js:728)
at Module._load (electron/js2c/asar.js:717)
at Function.Module._load (electron/js2c/asar.js:717)
at Module.require (internal/modules/cjs/loader.js:853)
当我转到 C:\Users\teste\AppData\Local\my-app\app-1.0.0\resources\app.asar.unpacked\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
时,文件就在那里并且可以完全访问
我运行宁windows10,节点v12.13.0
,电子8.2.1
与电子锻造
我的package.json是:
{
"name": "my-app",
"productName": "my-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\"",
"install": "electron-rebuild --pre-gyp-fix"
},
"keywords": [],
"author": "guzeda",
"license": "MIT",
"config": {
"forge": "./forge.config.js"
},
"dependencies": {
"@electron-forge/plugin-auto-unpack-natives": "^6.0.0-beta.50",
"@tensorflow/tfjs": "^1.5.1",
"@tensorflow/tfjs-node": "^1.5.1",
"electron-reload": "^1.5.0",
"electron-squirrel-startup": "^1.0.0",
"face-api.js": "^0.22.2",
"jquery": "^3.4.1",
"material-design-lite": "^1.3.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.50",
"@electron-forge/maker-deb": "^6.0.0-beta.50",
"@electron-forge/maker-rpm": "^6.0.0-beta.50",
"@electron-forge/maker-squirrel": "^6.0.0-beta.50",
"@electron-forge/maker-zip": "^6.0.0-beta.50",
"electron": "8.2.1",
"electron-rebuild": "^1.10.1"
}
}
我的forge.config是:
module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
name: "my-app"
}
}
],
plugins: [
['@electron-forge/plugin-auto-unpack-natives']
],
packagerConfig:{asar:true}
}
感谢任何帮助
我刚刚找到解决方案。发生这种情况是因为 dll 需要与 buddings 位于同一文件夹中。错误消息非常具有误导性。
最后需要编写一些 post 安装脚本来将正确的 dll 复制到文件夹中并且它运行良好
刚刚仔细检查了您的代码 - 与您的文件夹结构有关。
如果我可能会问,你为什么使用 tensorflow.js 而不是 python 等?