Created
January 4, 2018 19:30
-
-
Save kjin/48c261cca7a7a2fb6712fef6b2e8434e to your computer and use it in GitHub Desktop.
$ git diff v1.7.0^..v1.8.0 packages/grpc-native-core/**/*.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/grpc/grpc-node | |
cd grpc-node | |
git diff v1.7.0^..v1.8.0 packages/grpc-native-core/**/*.js > output.diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/grpc-native-core/src/grpc_extension.js b/packages/grpc-native-core/src/grpc_extension.js | |
index 77476f0..46e2721 100644 | |
--- a/packages/grpc-native-core/src/grpc_extension.js | |
+++ b/packages/grpc-native-core/src/grpc_extension.js | |
@@ -27,6 +27,26 @@ var binary = require('node-pre-gyp/lib/pre-binding'); | |
var path = require('path'); | |
var binding_path = | |
binary.find(path.resolve(path.join(__dirname, '../package.json'))); | |
-var binding = require(binding_path); | |
+var binding; | |
+try { | |
+ binding = require(binding_path); | |
+} catch (e) { | |
+ var fs = require('fs'); | |
+ var searchPath = path.dirname(path.dirname(binding_path)); | |
+ var searchName = path.basename(path.dirname(binding_path)); | |
+ var foundNames = fs.readdirSync(searchPath); | |
+ if (foundNames.indexOf(searchName) === -1) { | |
+ var message = `Failed to load gRPC binary module because it was not installed for the current system | |
+Expected directory: ${searchName} | |
+Found: [${foundNames.join(', ')}] | |
+This problem can often be fixed by running "npm rebuild" on the current system | |
+Original error: ${e.message}`; | |
+ var error = new Error(message); | |
+ error.code = e.code; | |
+ throw error; | |
+ } else { | |
+ throw e; | |
+ } | |
+} | |
module.exports = binding; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment