Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Module did not self-register #314

Open
samuel-zhen opened this issue May 6, 2022 · 2 comments
Open

Error: Module did not self-register #314

samuel-zhen opened this issue May 6, 2022 · 2 comments

Comments

@samuel-zhen
Copy link

samuel-zhen commented May 6, 2022

Describe the bug
Importing package in both main and worker thread will cause Error: Module did not self-register.
It will works if only main or worker thread is importing the package.

To Reproduce
main.js

import { Worker } from 'worker_threads';
import ZooKeeper from 'zookeeper';

console.log('Hi from main.js!');
const worker = new Worker('./worker.js');

worker.js

import ZooKeeper from 'zookeeper';

console.log('Hi from worker.js!');

package.json

{
  "name": "zk-worker-thread",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "node main.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "zookeeper": "^5.4.0"
  }
}

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Node.js version: v16.13.2
  • C/C++ compiler and version: -

Additional context
Hopefully this thread can provide some clue.
nodejs/node#21783

@DavidVujic
Copy link
Collaborator

Thank you for reporting!

The Node Worker thing isn't fully supported in this library yet.

@samuel-zhen
Copy link
Author

Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants