Skip to content

Commit

Permalink
Improve error message on Windows for version conflict (#2918)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrnl authored Oct 17, 2021
1 parent f37ca82 commit e475d9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/sharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ try {
help.push(
'- Consult the installation documentation: https://sharp.pixelplumbing.com/install'
);
// Check loaded
if (process.platform === 'win32') {
const loadedModule = Object.keys(require.cache).find((i) => /[\\/]build[\\/]Release[\\/]sharp(.*)\.node$/.test(i));
if (loadedModule) {
const [, loadedPackage] = loadedModule.match(/node_modules[\\/]([^\\/]+)[\\/]/);
help.push(`- Ensure version aligns with: "npm ls sharp". Now sharp already loaded in: "${loadedPackage}"`);
}
}
console.error(help.join('\n'));
process.exit(1);
}

0 comments on commit e475d9e

Please sign in to comment.