-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
child_process.fork doesn't work #70
Comments
@cage1618 did you figure out a workaround? |
yes,when I remove the Insted, pass example code: // main.js
const {fork} = require('child_process');
const child = fork('/path-to-child-process-extry.js', ['/path-of-you-want-to-specify'], {
...options
});
// child.js
// override child process.cwd
// put this code at the begining of this file
Object.defineProperty(process, 'cwd', {
writable: false,
enumerable: false,
configurable: false,
value: function cwd() {
return process.argv[2];
}
});
|
I would like to re-open a discussion here. Seems this problem has been already widely discussed on vercel#897 (comment) The problem is that ATM when a pkg binary invokes itself it considers the invocation to pass the call down to nodejs runtime instead. I accept suggestions about how we could fix this in order to make it work in both scenarios |
Tagging here all partecipants of previous issue: @edvald This is the active fork of pkg (with all latest nodejs versions support) and I would like your opinion about the best way to fix this to keep back compatibility and also allow users to call the binary. |
If i remove Unfortunately @cage1618 why do you need to override UPD you can specify |
@igorklopov thanks for your comment, didn't know you were still active here on GH 😄 Nice to see you, would be awesome to have you working at this (your) project again, PM me if you are interested and I will be more then pleased to make you maintainer/admin of the repos 🙏🏼 |
Thanks @robertsLando! Nice to see pkg maintained while i was away 🙂 I didn't have much free time and don't have it now, but feel free to ping me like this. We'll see how it goes. |
@igorklopov Sure thing! Thanks 🙏🏼 |
An example issue is here: dotenvx/dotenvx#276 In this case them are using this patch to make it work and allow the program to call itself. Issue is that actually when this happens pkg by default invokes nodejs instead |
I want to use process.cwd() get the cwd path in another file. |
What version of pkg are you using?
5.11.12
What version of Node.js are you using?
20.11.1
What operating system are you using?
mac os
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node20
Describe the Bug
I want to fork a child process in packaged executable, but something error occoued:
services/broker.js has set to assets but no effect
Expected Behavior
fork process can work
To Reproduce
The text was updated successfully, but these errors were encountered: