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?
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.
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"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With