为什么BrainJ(服务器侧)在Android中投掷错误?
我正在尝试在Android(Termux)中使用brainjs
。在我的窗户中,这绝对可以正常工作。但是,当我在Android中运行npm start
时,我会得到:
node:internal/modules/cjs/loader:1183
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen failed: cannot locate symbol "eglChooseConfig" referenced by "/data/data/com.termux/files/home/disbot/node_modules/gl/build/Release/webgl.node"...
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at bindings (/data/data/com.termux/files/home/disbot/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/data/data/com.termux/files/home/disbot/node_modules/gl/src/javascript/native-gl.js:1:40)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32) {
code: 'ERR_DLOPEN_FAILED'
}
Node.js v17.9.0
我的triber.js
文件
import brain from "brain.js";
import fs from "fs";
const network = new brain.recurrent.LSTM();
const rawData = fs.readFileSync("rawData.json");
const data = JSON.parse(rawData).map((qna) => ({
input: qna.question,
output: qna.answer,
}));
network.train(data, {
iterations: 100,
});
fs.writeFileSync(
"trainedData.json",
JSON.stringify(network.toJSON())
);
这是安装brain.js
package时的日志
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
[##################] / reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
> [email protected] install
> prebuild-install || node-gyp rebuild
gyp info it worked if it ends with oktiming reifyNode:node_modules/gl Completed in 16029ms
gyp info using [email protected]
gyp info using [email protected] | android | ia32
gyp info find Python using Python version 3.10.4 found at "/data/data/com.termux/files/usr/bin/python3"
(node:3927) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
(Use `node --trace-deprecation ...` to show where the warning was created)
gyp info spawn /data/data/com.termux/files/usr/bin/python3
gyp info spawn args [
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/gl/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/.cache/node-gyp/17.9.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/data/data/com.termux/files/home/.cache/node-gyp/17.9.0',
gyp info spawn args '-Dnode_gyp_dir=/data/data/com.termux/files/home/disbot/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/data/data/com.termux/files/home/.cache/node-gyp/17.9.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/data/data/com.termux/files/home/disbot/node_modules/gl',
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 'build',
gyp info spawn args '-Goutput_dir=.'
info spawn args ]####] \ reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
gyp info spawn make] \ reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/data/data/com.termux/files/home/disbot/node_modules/gl/build'
CXX(target) Release/obj.target/webgl/src/native/bindings.o
CXX(target) Release/obj.target/webgl/src/native/webgl.oe_modules/gl Completed in 16029ms
CXX(target) Release/obj.target/webgl/src/native/procs.oe_modules/gl Completed in 16029ms
SOLINK_MODULE(target) Release/obj.target/webgl.node:node_modules/gl Completed in 16029ms
COPY Release/webgl.nodeify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
make: Leaving directory '/data/data/com.termux/files/home/disbot/node_modules/gl/build'9ms
gyp info ok
> [email protected] postinstall
> node bin/postinstall || exit 0
。 JSON
{
"name": "brainjs",
"version": "1.0.0",
"description": "brainjs",
"main": "index.js",
"type": "module",
"scripts": {
"start": "nodemon trainer.js"
},
"keywords": [
"brainjs"
],
"author": "KasRoudra",
"license": "MIT",
"dependencies": {
"brain.js": "^2.0.0-beta.15",
"nodemon": "^2.0.16"
},
}
I am trying to use brainjs
in my android(termux). In my windows, this is working absolutely fine. But when I run npm start
in android, I get this:
node:internal/modules/cjs/loader:1183
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen failed: cannot locate symbol "eglChooseConfig" referenced by "/data/data/com.termux/files/home/disbot/node_modules/gl/build/Release/webgl.node"...
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at bindings (/data/data/com.termux/files/home/disbot/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/data/data/com.termux/files/home/disbot/node_modules/gl/src/javascript/native-gl.js:1:40)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32) {
code: 'ERR_DLOPEN_FAILED'
}
Node.js v17.9.0
My trainer.js
file
import brain from "brain.js";
import fs from "fs";
const network = new brain.recurrent.LSTM();
const rawData = fs.readFileSync("rawData.json");
const data = JSON.parse(rawData).map((qna) => ({
input: qna.question,
output: qna.answer,
}));
network.train(data, {
iterations: 100,
});
fs.writeFileSync(
"trainedData.json",
JSON.stringify(network.toJSON())
);
This is the log while installing brain.js
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
[##################] / reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
> [email protected] install
> prebuild-install || node-gyp rebuild
gyp info it worked if it ends with oktiming reifyNode:node_modules/gl Completed in 16029ms
gyp info using [email protected]
gyp info using [email protected] | android | ia32
gyp info find Python using Python version 3.10.4 found at "/data/data/com.termux/files/usr/bin/python3"
(node:3927) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
(Use `node --trace-deprecation ...` to show where the warning was created)
gyp info spawn /data/data/com.termux/files/usr/bin/python3
gyp info spawn args [
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/gl/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/disbot/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/data/data/com.termux/files/home/.cache/node-gyp/17.9.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/data/data/com.termux/files/home/.cache/node-gyp/17.9.0',
gyp info spawn args '-Dnode_gyp_dir=/data/data/com.termux/files/home/disbot/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/data/data/com.termux/files/home/.cache/node-gyp/17.9.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/data/data/com.termux/files/home/disbot/node_modules/gl',
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 'build',
gyp info spawn args '-Goutput_dir=.'
info spawn args ]####] \ reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
gyp info spawn make] \ reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/data/data/com.termux/files/home/disbot/node_modules/gl/build'
CXX(target) Release/obj.target/webgl/src/native/bindings.o
CXX(target) Release/obj.target/webgl/src/native/webgl.oe_modules/gl Completed in 16029ms
CXX(target) Release/obj.target/webgl/src/native/procs.oe_modules/gl Completed in 16029ms
SOLINK_MODULE(target) Release/obj.target/webgl.node:node_modules/gl Completed in 16029ms
COPY Release/webgl.nodeify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
make: Leaving directory '/data/data/com.termux/files/home/disbot/node_modules/gl/build'9ms
gyp info ok
> [email protected] postinstall
> node bin/postinstall || exit 0
package.json
{
"name": "brainjs",
"version": "1.0.0",
"description": "brainjs",
"main": "index.js",
"type": "module",
"scripts": {
"start": "nodemon trainer.js"
},
"keywords": [
"brainjs"
],
"author": "KasRoudra",
"license": "MIT",
"dependencies": {
"brain.js": "^2.0.0-beta.15",
"nodemon": "^2.0.16"
},
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
相同的错误。
NPM重建
帮助我Same error.
npm rebuild
helps me