File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
packages/grpc-native-core/src Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,26 @@ var binary = require('node-pre-gyp/lib/pre-binding');
2727var path = require ( 'path' ) ;
2828var binding_path =
2929 binary . find ( path . resolve ( path . join ( __dirname , '../package.json' ) ) ) ;
30- var binding = require ( binding_path ) ;
30+ var binding ;
31+ try {
32+ binding = require ( binding_path ) ;
33+ } catch ( e ) {
34+ var fs = require ( 'fs' ) ;
35+ var searchPath = path . dirname ( path . dirname ( binding_path ) ) ;
36+ var searchName = path . basename ( path . dirname ( binding_path ) ) ;
37+ var foundNames = fs . readdirSync ( searchPath ) ;
38+ if ( foundNames . indexOf ( searchName ) === - 1 ) {
39+ var message = `Failed to load gRPC binary module because it was not installed for the current system
40+ Expected directory: ${ searchName }
41+ Found: [${ foundNames . join ( ', ' ) } ]
42+ This problem can often be fixed by running "npm rebuild" on the current system
43+ Original error: ${ e . message } ` ;
44+ var error = new Error ( message ) ;
45+ error . code = e . code ;
46+ throw error ;
47+ } else {
48+ throw e ;
49+ }
50+ }
3151
3252module . exports = binding ;
You can’t perform that action at this time.
0 commit comments