为什么BrainJ(服务器侧)在Android中投掷错误?

发布于 2025-01-26 01:38:47 字数 6317 浏览 3 评论 0原文

我正在尝试在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春风十里 2025-02-02 01:38:47

相同的错误。 NPM重建帮助我

Same error. npm rebuild helps me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文