Firebase-admin-node: Unable to deploy to AWS EBS

Created on 10 Oct 2017  ยท  12Comments  ยท  Source: firebase/firebase-admin-node

[REQUIRED] Step 2: Describe your environment

  • Operating System version: AWS Ubuntu Linux 16
  • Firebase SDK version: 5.4.2
  • Library version:
  • Firebase Product: Messaging (Admin sdk)

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

npm install --save firebase-admin and run eb-deploy
The deploy fails with:

============= i-05310204bd3adbe90 ==============
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------

module.js:487
    throw err;
    ^

Error: Cannot find module 'grpc'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/app/current/node_modules/firebase-admin/node_modules/@google-cloud/common-grpc/src/service.js:26:12)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚             npm update check failed              โ”‚
โ”‚       Try running with sudo or get access        โ”‚
โ”‚       to the local update config store via       โ”‚
โ”‚ sudo chown -R $USER:$(id -gn $USER) /tmp/.config โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

> [email protected] start /var/app/current

Here is my package.json

{
  "name": "App",
  "version": "1.0.0",
  "description": "App backend code",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ParsePlatform/parse-server-example"
  },
  "license": "MIT",
  "dependencies": {
    "body-parser": "^1.17.2",
    "express": "^4.15.4",
    "firebase-admin": "5.2.1",
    "kerberos": "~0.0.x",
    "parse": "^1.10.0",
    "parse-server": "^2.6.0",
    "pug": "^2.0.0-rc.4",
    "shortid": "^2.2.8"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.3"
  }
}

Most helpful comment

appreciate you @albinekb , upgraded t2.mico => t2.medium and it worked.

All 12 comments

Can you check if the grpc package is installed under node_modules?

How do I check the contents of node_modules folder in ebs? In my local node_modules folder I see the grpc lib.

This should be fixed now: https://firebase.google.com/support/release-notes/admin/node#5.4.3

We no longer load Firestore/gRPC packages unless admin.firestore() is called explicitly.

@hiranya911
This still doesn't work for me. I can't deploy to EB if I have firebase-admin greater than 4.2.1

I have to use firestore for my project, are there any workarounds?

Also, when I take out any firestore call (it was easy as I was only using it in one place) I get

  Failed to execute '/opt/elasticbeanstalk/node-install/node-v8.8.1-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v8.8.1-linux-x64/lib/node_modules/n
pm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/tmp/deployment/application/node_modules/grpc/src/node/ex
tension_binary/node-v57-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/tmp/deployment/application/node_modules/grpc/src/node/extension_bina
ry/node-v57-linux-x64-glibc' (1)
  npm WARN [email protected] No repository field.

  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --library=static_library`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the [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!     /tmp/.npm/_logs/2018-02-13T03_32_49_130Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v8.8.1-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2018/02/13 03:32:49 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log

  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.8.1-linux-x64/bin/npm', '--production', 'install']' returned non-zero exitstatus 1 (Executor::NonZeroExitStatus)

So I can't use it even if I don't call firestore

@shadow1349 I switched from NPM to yarn on EB and it works great now.

@rtkhanas I'm afraid I can't switch my whole company over to yarn

@shadow1349 anyway the problems looks like NPM is installing some dependencies to a wrong folder on AWS. Maybe, not really related to firebase-admin-node, but more to NPM itself.

Hello all, have this issue been resolved? I am getting it too. Any suggestions?

I have this issue too, we we're running t2.micro with 512MB ram, but compiling GRPC module seems to only work with t2.medium (4GB ram). Why is this package installed when I'm just using firebase.messaging() ?

appreciate you @albinekb , upgraded t2.mico => t2.medium and it worked.

For any latecomers to this thread: I encountered this issue when deploying to Elastic Beanstalk. Installing grpc was breaking during node-gypwith a permission error:

node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/grpc/src/node'

I was able to resolve temporarily by installing with unsafe-perm=true as detailed here.

@sthielen thank you. This worked perfectly for me

Was this page helpful?
0 / 5 - 0 ratings