Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJs Error - Failed to load gRPC binary module because it was not installed for the current system Expected directory?

Tags:

node.js

grpc

I am running my NodeJs App and i am getting an error.

sudo /usr/local/bin/node app.js    
    Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/home/projects/kj_app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc
/grpc_node.node'
    at Object.<anonymous> (/home/projects/kj_app/node_modules/grpc/src/grpc_extension.js:53:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/projects/kj_app/node_modules/grpc/src/client.js:37:12)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

Edit

    sudo /usr/local/bin/npm rebuild

    > [email protected] postinstall /home/projects/kj_app/node_modules/protobufjs
> node scripts/postinstall
> [email protected] install /home/projects/kj_app/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
[grpc] Success: "/home/projects/kj_app/node_modules/grpc/src/node/extension_binary/node-v59-linux-x64-glibc/grpc_node.node" al
ready installed
Pass --update-binary to reinstall or --build-from-source to recompile
> @google-cloud/[email protected] install /home/projects/kj_app/node_modules/@google-cloud/profiler
> node-gyp rebuild
gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Linux 4.9.0-6-amd64
gyp ERR! command "/opt/bitnami/nodejs/bin/.node.bin" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "
rebuild"
gyp ERR! cwd /home/projects/kj_app/node_modules/@google-cloud/profiler
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google-cloud/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-10T16_06_40_444Z-debug.log
like image 452
Sudhanshu Gaur Avatar asked Apr 10 '18 15:04

Sudhanshu Gaur


4 Answers

It seems like you have some verion conflict

Expected directory: node-v57-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]

Have you tried running npm rebuild in your app folder?

like image 113
Tnc Andrei Avatar answered Nov 09 '22 13:11

Tnc Andrei


npm rebuild worked for me :)

Thanx to everyone who replied

(Using n with node v8.15.1 and npm 6.4.1)

like image 32
guya Avatar answered Nov 09 '22 14:11

guya


I had the same problem (using nvm) and found that my selected node version was different than the one in .nvmrc. I did the following steps to fix it:

rm -rf node_modules
nvm use
yarn

I removed node_modules because it might have installed a version of some dependencies for the wrong version of node, so I want to ensure I have the correct libraries for the selected version.

When I do nvm use, it picks the version of node from the .nvmrc in my project.

You can use npm install instead of yarn. That's just how my project is set up.

like image 12
Mnebuerquo Avatar answered Nov 09 '22 13:11

Mnebuerquo


I had the same problem with Google Cloud Functions and Emulator, after migration from node 6 to node 8.

My Solution:

  1. npm rebuild // no effect
  2. delete node_modules folder in the functions folder
  3. npm install
  4. in the functions folder call: npm i --save firebase-functions
  5. firebase serve // start the emulator and try
like image 10
Sean Stayns Avatar answered Nov 09 '22 14:11

Sean Stayns