NodeJS 为什么brainjs(服务器端)在android中抛出错误?

rnmwe5a2  于 2023-03-17  发布在  Node.js
关注(0)|答案(1)|浏览(105)

我试着在我的安卓系统(termux)中使用brainjs,在我的windows系统中,这个功能运行得非常好,但是当我在安卓系统中运行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

我的trainer.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时的日志

npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: 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 request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[##################] / reify:webgpu: timing reifyNode:node_modules/gl Completed in 16029ms
> gl@4.9.2 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 node-gyp@7.1.2
gyp info using node@17.9.0 | 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

> nodemon@2.0.16 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"
  },
}
wbgh16ku

wbgh16ku1#

同样的错误。“npm rebuild”帮助我

相关问题