From 6712aeab6050d6fdc61937105921507fd043cd5f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 16 May 2024 14:43:31 +0200 Subject: [PATCH] Fix `spawn EINVAL` on Windows when using Node > 20.12.2 --- lib/utils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 50264bdf0..f9e6cd396 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -70,7 +70,12 @@ class SpawnError extends Error { */ function spawnProcess(command, args, options) { return new BbPromise((resolve, reject) => { - const child = childProcess.spawn(command, args, options); + const child = childProcess.spawn(command, args, { + ...options, + // nodejs 20 on windows doesn't allow `.cmd` command to run without `shell: true` + // https://github.com/serverless-heaven/serverless-webpack/issues/1791 + shell: /^win/.test(process.platform) + }); let stdout = ''; let stderr = ''; // Configure stream encodings