From cccd1635c5d946b30d846f39cceab83a5975af9a Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 6 Nov 2023 09:40:38 +0000 Subject: [PATCH] Small improvements to install error help text --- lib/libvips.js | 2 +- lib/sharp.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libvips.js b/lib/libvips.js index ebb41fd0..b86046bb 100644 --- a/lib/libvips.js +++ b/lib/libvips.js @@ -16,7 +16,7 @@ const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).versio const prebuiltPlatforms = [ 'darwin-arm64', 'darwin-x64', - 'linux-arm', 'linux-arm64', 'linux-x64', + 'linux-arm', 'linux-arm64', 'linux-s390x', 'linux-x64', 'linuxmusl-arm64', 'linuxmusl-x64', 'win32-ia32', 'win32-x64' ]; diff --git a/lib/sharp.js b/lib/sharp.js index 3b9a0078..d4eaae07 100644 --- a/lib/sharp.js +++ b/lib/sharp.js @@ -30,7 +30,10 @@ try { help.push('Possible solutions:'); // Common error messages if (prebuiltPlatforms.includes(runtimePlatform)) { + const [os, cpu] = runtimePlatform.split('-'); help.push('- Add an explicit dependency for the runtime platform:'); + help.push(` npm install --os=${os} --cpu=${cpu} sharp`); + help.push(' or'); help.push(` npm install --force @img/sharp-${runtimePlatform}`); } else { help.push(`- The ${runtimePlatform} platform requires manual installation of libvips >= ${minimumLibvipsVersion}`); @@ -57,9 +60,7 @@ try { help.push(' yarn config set nodeLinker node-modules'); } // Link to installation docs - if (isLinux && /Module did not self-register/.test(errLocal.message + errPackage.message)) { - help.push('- Using worker threads on Linux? See https://sharp.pixelplumbing.com/install#worker-threads'); - } else if (isWindows && /The specified procedure could not be found/.test(errPackage.message)) { + if (isWindows && /The specified procedure could not be found/.test(errPackage.message)) { help.push('- Using the canvas package on Windows? See https://sharp.pixelplumbing.com/install#canvas-and-windows'); } else { help.push('- Consult the installation documentation: https://sharp.pixelplumbing.com/install');