From 4331ac29d0003ed66e451f411435d5253dae20c1 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Sat, 29 Aug 2026 22:10:47 +0500 Subject: [PATCH] Prevent TypeError when module load error has no code --- lib/sharp.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sharp.mjs b/lib/sharp.mjs index d1b6bd4a5..33f9c7517 100644 --- a/lib/sharp.mjs +++ b/lib/sharp.mjs @@ -112,8 +112,8 @@ if (!sharp) { const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`]; errors.forEach((err) => { - if (!err.code.endsWith("MODULE_NOT_FOUND")) { - help.push(`${err.code}: ${err.message}`); + if (!err.code?.endsWith("MODULE_NOT_FOUND")) { + help.push(err.code ? `${err.code}: ${err.message}` : err.message); } }); const messages = errors.map((err) => err.message).join(" ");