Commit 01f9c181 by xzyfer

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.
parent 8889d120
...@@ -147,7 +147,11 @@ sass.getBinaryPath = function(throwIfNotExists) { ...@@ -147,7 +147,11 @@ sass.getBinaryPath = function(throwIfNotExists) {
} }
if (!fs.existsSync(binaryPath) && 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; return binaryPath;
......
...@@ -205,7 +205,7 @@ describe('library detection', function() { ...@@ -205,7 +205,7 @@ describe('library detection', function() {
assert.throws(function() { assert.throws(function() {
fs.renameSync(originalBin, renamedBin); fs.renameSync(originalBin, renamedBin);
process.sass.getBinaryPath(true); process.sass.getBinaryPath(true);
}, /`libsass` bindings not found/); }, /The `libsass` binding was not found/);
fs.renameSync(renamedBin, originalBin); fs.renameSync(renamedBin, originalBin);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment