Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-v57-linux-x64/grpc_node.node missing

When following exactly these steps:

https://firebase.google.com/docs/admin/setup

And deploying to my server, I get this error:

2017-10-16 19:19:56 4199bf47fc2d ---> Starting app
2017-10-16 19:19:56 4199bf47fc2d Detected server.js file
2017-10-16 19:19:57 4199bf47fc2d module.js:529
2017-10-16 19:19:57 4199bf47fc2d     throw err;
2017-10-16 19:19:57 4199bf47fc2d     ^
2017-10-16 19:19:57 4199bf47fc2d 
2017-10-16 19:19:57 4199bf47fc2d Error: Cannot find module '/data/app/node_modules/firebase-admin/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64/grpc_node.node'
2017-10-16 19:19:57 4199bf47fc2d     at Function.Module._resolveFilename (module.js:527:15)
2017-10-16 19:19:57 4199bf47fc2d     at Function.Module._load (module.js:476:23)
2017-10-16 19:19:57 4199bf47fc2d     at Module.require (module.js:568:17)
2017-10-16 19:19:57 4199bf47fc2d     at require (internal/module.js:11:18)
2017-10-16 19:19:57 4199bf47fc2d     at Object.<anonymous> (/data/app/node_modules/firebase-admin/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
2017-10-16 19:19:57 4199bf47fc2d     at Module._compile (module.js:624:30)
2017-10-16 19:19:57 4199bf47fc2d     at Object.Module._extensions..js (module.js:635:10)
2017-10-16 19:19:57 4199bf47fc2d     at Module.load (module.js:545:32)
2017-10-16 19:19:57 4199bf47fc2d     at tryModuleLoad (module.js:508:12)
2017-10-16 19:19:57 4199bf47fc2d     at Function.Module._load (module.js:500:3)

It was installed in a new folder, newest npm and all, removed node_modules map reinstalled, npm install --unsafe-perm, npm rebuild etc. Nothing is working. Why isn't the module being installed?

like image 776
NoKey Avatar asked Oct 16 '17 17:10

NoKey


2 Answers

This helped in my case:

npm rebuild --target=8.1.0 --target_platform=linux --target_arch=x64 --target_libc=glibc --update-binary

It downloads the required binary to your node_modules/grpc directory.

I run macOS X on my dev machine and I’m deploying to AWS Lambda; this keeps both runtime versions installed, which means I can develop and test locally and then deploy to Lambda.

like image 123
AndreasPizsa Avatar answered Oct 13 '22 20:10

AndreasPizsa


I just ran into the same issue. For us the problem was that we're installing the node modules on a mac and the install of firebase-admin is putting a platform specific file in for the binary.

After running the install and checking this directory I see this:

$ ls node_modules/firebase-admin/node_modules/grpc/src/node/extension_binary/
node-v48-darwin-x64

But the environment that is running the lamba is looking for:

 node-v48-linux-x64

An easy solution is to run the npm install in the same environment that the lambda is running in using docker. In our case I found that the lambci project has prebuilt docker containers for this exact use case. Here I've added an npm script line to handle the build:

  "scripts": {
      "package": "rm -rf node_modules && docker run -v $PWD:/var/task -w /var/task lambci/lambda:build-nodejs6.10 npm install"
  },
like image 32
Christopher Fitzner Avatar answered Oct 13 '22 21:10

Christopher Fitzner