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

Commit

Permalink
Provide a useful error message when the binding is not found
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xzyfer committed Sep 16, 2015
1 parent 8889d12 commit 01f9c18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ sass.getBinaryPath = function(throwIfNotExists) {
}

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

return binaryPath;
Expand Down
2 changes: 1 addition & 1 deletion test/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('library detection', function() {
assert.throws(function() {
fs.renameSync(originalBin, renamedBin);
process.sass.getBinaryPath(true);
}, /`libsass` bindings not found/);
}, /The `libsass` binding was not found/);

fs.renameSync(renamedBin, originalBin);
});
Expand Down

0 comments on commit 01f9c18

Please sign in to comment.