Skip to content

Commit 37d576b

Browse files
committed
fix(spawn): resolve relative paths to prevent ENOENT errors
Some node installations have trouble with relative paths passed to child_process.spawn() - so in those cases we resolve the full path instead. ref #5649
1 parent fa257dd commit 37d576b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/common/child-process.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as child_process from "child_process";
2+
import { resolve } from "path";
23
import { EventEmitter } from "events";
34
import {
45
IChildProcess,
@@ -76,6 +77,11 @@ export class ChildProcess extends EventEmitter implements IChildProcess {
7677
args?: string[],
7778
options?: any
7879
): child_process.ChildProcess {
80+
if (command.charAt(0) === ".") {
81+
// resolve relative paths to full paths to avoid node Spawn ENOENT errors on some setups.
82+
const cwd = options?.cwd ?? process.cwd();
83+
command = resolve(cwd, command);
84+
}
7985
this.$logger.debug(
8086
"spawn: %s %s",
8187
command,

0 commit comments

Comments
 (0)