Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 01f9c18

Browse files
committed
Provide a useful error message when the binding is not found
Currently we show the unhelpful for `libsass` binding not found. This accounts for a number of reoccurring GitHub issues. It's also the second largest driver of Google traffic to the node-sass GitHub repo.
1 parent 8889d12 commit 01f9c18

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/extensions.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ sass.getBinaryPath = function(throwIfNotExists) {
147147
}
148148

149149
if (!fs.existsSync(binaryPath) && throwIfNotExists) {
150-
throw new Error(['`libsass` bindings not found in ', binaryPath, '. Try reinstalling `node-sass`?'].join(''));
150+
throw new Error([
151+
['The `libsass` binding was not found in', binaryPath].join(' '),
152+
['This usually happens because your node version has changed.'],
153+
['Run `npm rebuild node-sass` to build the binding for your current node version.'],
154+
].join('\n'));
151155
}
152156

153157
return binaryPath;

test/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('library detection', function() {
205205
assert.throws(function() {
206206
fs.renameSync(originalBin, renamedBin);
207207
process.sass.getBinaryPath(true);
208-
}, /`libsass` bindings not found/);
208+
}, /The `libsass` binding was not found/);
209209

210210
fs.renameSync(renamedBin, originalBin);
211211
});

0 commit comments

Comments
 (0)