threads.js: Packaging with zeit/pkg doesn't seem to work properly
Hi,
just tried to package a simple app which uses threads.js
with https://github.com/zeit/pkg and it didn’t seem to work that nicely. There is no error displayed on packaging, but when running the app i’m greeted with:
pkg/prelude/bootstrap.js:1176
throw error;
^
Error: Cannot find module '../config'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call.
2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Function.Module._resolveFilename (module.js:545:15)
at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1278:46)
at Function.Module._load (module.js:472:25)
at Module.require (module.js:594:17)
at Module.require (pkg/prelude/bootstrap.js:1157:31)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\snapshot\WebstormProjects\some-project\node_modules\threads\lib\worker.node\worker.js:18:15)
at Module._compile (pkg/prelude/bootstrap.js:1252:22)
at Object.Module._extensions..js (module.js:661:10)
at Module.load (module.js:563:32)
The line in question require
ing is in lib\worker.node\worker.js:18:15
.
I use the threads.js
as follows:
const threads = require('threads');
const thread = threads.spawn(`${__dirname}/worker.js`);
Anybody has solved this yet or got pointers on what might be the culprit?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 17 (7 by maintainers)
Commits related to this issue
- added this seemed to have fixed it. answer found here in another package: https://github.com/andywer/threads.js/issues/92 — committed to rogerthoang/piscina-example-pkg by rogerthoang 3 years ago
I was getting an error that the application could not find the module worker. This thread helped me get rid of that error… But when I require(‘threads’).Pool in one particular file… the application does not even start… When I do the require in a few different places it seems to work… Would be nice if pkg would ever respond to their issues, but they are getting more scarce… I have added most of you suggestions… and done dozens of iterations around those suggestions… Will update if i get it working.
Sure, thanks!