Hi all I am requiring transformer js in my node js application with typescript in a file called worker.js as
const TransformersApi = Function('return import("@xenova/transformers")')();
const { CLIPVisionModelWithProjection, RawImage, AutoProcessor } = await TransformersApi;
As other way of requiring module was not working with worker-thread. It is working fine when i am running file for the first time. but its giving error when request coming for the next time and executing second line of code
const { CLIPVisionModelWithProjection, RawImage, AutoProcessor } = await TransformersApi;
Error: Module did not self-register: '/server/node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node'.
at Module._extensions..node (/server/lib/internal/modules/cjs/loader.js:1340:18)
at Module.load (/home/server/lib/internal/modules/cjs/loader.js:1119:32)
at Module._load (/home/server/lib/internal/modules/cjs/loader.js:960:12)
at Module.require (/home/server/lib/internal/modules/cjs/loader.js:1143:19)
at require (/home/server/lib/internal/modules/cjs/helpers.js:110:18)
at Object.<anonymous> (/home/server/node_modules/onnxruntime-node/dist/binding.js:9:1)
at Module._compile (/home/server/lib/internal/modules/cjs/loader.js:1256:14)
at Module._extensions..js (/home/server/lib/internal/modules/cjs/loader.js:1310:10)
at Module.load (/home/server/lib/internal/modules/cjs/loader.js:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12) {code: 'ERR_DLOPEN_FAILED', stack: 'Error: Module did not self-register: '/home/r…oad (node:internal/modules/cjs/loader:960:12)', message: 'Module did not self-register: '/home/…napi-v3/linux/x64/onnxruntime_binding.node'.'}
How to resolve this? Note: I have tried these solutions already :
- npm rebuild
- deleted node_module folder and run npm install.
- change package.json as add "type": "module"(this gives error as i am using commonjs for external module)
- change tsconfig.js as "module": "commonjs", "target": "es2016", "sourceMap": true
This is Super Duper Duper annoying!
I found this comment...
https://github.com/lovell/sharp/issues/3295#issuecomment-1186927843
and tried this...
Now I get a different error but I'm not sure if it's related or just another problem that has now been exposed...
[unhandledRejection] connect ECONNREFUSED 127.0.0.1:53191
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1602:16)