Skip to content

Commit

Permalink
fix: remove ts-node/esm loader from execArgv when using child_process…
Browse files Browse the repository at this point in the history
….fork
  • Loading branch information
mdonnalley committed Aug 11, 2023
1 parent 2abc9bc commit 167419a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class Yarn {
}

fork(modulePath: string, args: string[] = [], options: any = {}): Promise<void> {
debug('child_process.fork options:', options)
return new Promise((resolve, reject) => {
const forked = fork(modulePath, args, options)
forked.stderr?.on('data', (d: any) => process.stderr.write(d))
Expand All @@ -43,6 +44,7 @@ export default class Yarn {
}

spawn(executable: string, args: string[] = [], options: any = {}): Promise<void> {
debug('child_process.spawn options:', options)
return new Promise((resolve, reject) => {
const spawned = spawn(executable, args, {...options, shell: true})
spawned.stderr.setEncoding('utf8')
Expand Down Expand Up @@ -100,6 +102,9 @@ export default class Yarn {
cwd,
stdio: [0, null, null, 'ipc'],
env: npmRunPath.env({cwd, env: process.env}),
// Remove --loader ts-node/esm from execArgv so that the subprocess doesn't fail if it can't find ts-node.
// The ts-node/esm loader isn't need to execute yarn commands anyways.
execArgv: process.execArgv.join(' ').replace('--loader ts-node/esm', '').split(' ').filter(Boolean),
}

if (opts.verbose) {
Expand Down

0 comments on commit 167419a

Please sign in to comment.