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 a ts file with import statement and args && execArgv !== undefined #619
Comments
You're overriding Please read the documentation for functions you're trying to use: https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options.
|
I think the real issue here is I have the same problem and the title containing things like I'm also running my code via If I run code like It may be recommended to use something like Any ideas on how to achieve this? |
@jrhite This should work: const childProcess = fork(join(__dirname, 'child-process.ts'), ['-r', 'ts-node/register']);` |
This is what worked for me. fork(
'child-process.ts'
, []
, {
execArgv: ['-r', 'ts-node/register']
}
) |
I know this is old, but hopefully it helps someone. @RichAyotte's response worked for me. In my case I needed to specify the relative path to the file: |
Heads up: This should never have been an issue. If you are encountering an issue please let me know by creating a new issue. I did additional work in January to ensure args from the Edit: The original issue is still valid though, if you override |
You can also omit the extension, once compiled the resulting JavaScript will be used. Ex. ParentProcess.ts
ChlidProcess.ts
|
How can I use |
index.ts
test.ts
Note: You need
ts-node
,typescript
, and@types/node
I was using node version
10.4.1
It will work if you:
Remove test.ts's import statement,
Change either empty array to
undefined
in index.ts,Or use vanilla js/compiled typescript
Note: the error is not the * it will be at the same spot no matter what you import.
I actually ran into this in a real project too, incredible.
The text was updated successfully, but these errors were encountered: