0

为了同时执行多条SQL语句,多线程以worker_threads的形式实现。应用程序本身使用 node-jdbc 库 ( https://github.com/CraZySacX/node-jdbc ) 通过数据库的 JDBC 接口查询数据。

注意:该项目是用打字稿编写的。

版本:

  • 节点:12.18.1

  • 打字稿:3.6.4

  • 数据库:0.7.5

Error: Module did not self-register: '\\?\C:\projectFolder\node_modules\java\builde\Release\nodejavabridge_bindings.node' 
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1188:18)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\projectFolder\node_modules\java\lib\nodeJavaBridge.js:21:16)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Module._compile (C:\projectFolder\node_modules\source-map-support\source-map-support.js:547:25)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32) 

当我尝试在子进程中通过 require 导入 JDBC 库时发生错误。主进程中的 require 执行没有问题。

// nodeJavaBridge.js
'use strict';

process.env.PATH += require('../build/jvm_dll_path.json');

var _ = require('lodash');
var async = require('async');
var path = require('path');
var fs = require('fs');
var binaryPath = null;
try {
  if (fs.statSync && fs.statSync(path.join(__dirname, "../build/Debug/nodejavabridge_bindings.node")).isFile()) {
    binaryPath = path.resolve(path.join(__dirname, "../build/Debug/nodejavabridge_bindings.node"));
    console.log('****** NODE-JAVA RUNNING IN DEBUG MODE ******');
  }
} catch (e) {
  // do nothing fs.statSync just couldn't find the file
}
if (!binaryPath) {
  binaryPath = path.resolve(path.join(__dirname, "../build/Release/nodejavabridge_bindings.node"));
}
// works on mainthread fails on child
var bindings = require(binaryPath);

解决方案尝试:

如果有人可以帮助我,那就太好了。

4

0 回答 0