12

I'm attempting to add the GRPC dependency to a node elastic beanstalk application and all of my deployments are failing. Once I remove the GRPC dependency from my package.json my deployments work.

The error is

ERROR: Failed to run npm install.  
> grpc@1.10.1 install /tmp/deployment/application/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp ERR! Pre-built binaries not installable for grpc@1.10.1 
and node@8.9.3 (node-v57 ABI, glibc) (falling back to source compile 
with node-gyp) 
node-pre-gyp ERR! Hit error EACCES: permission denied, mkdir 
'/tmp/deployment/application/node_modules/grpc/src/node' 
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied

I've had this issue on another node app and was able to resolve it by running npm --save-dev eb-fix-npm but it does not work with this app. I also sometimes get an error along the lines of `cannot create symbolic link, file already exists (paraphrased).

I have this file set up as well to attempt to fix this.

 files:
   "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh" :
     mode: "000775"
     owner: root
     group: root
     content: |
       #!/bin/bash          
       function error_exit

       {
         eventHelper.py --msg "$1" --severity ERROR
         exit $2
       }

       export HOME=/home/ec2-user

       OUT=$(/opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install 2>&1) || error_exit "Failed to run npm install.  $OUT" $?
       echo $OUT

Thanks for the help

Lucas Crostarosa
  • 1,192
  • 6
  • 13
  • 26

5 Answers5

12

For anyone using bcrypt library in your project.

You will get this error if you are trying to deploy your code using Elastic Beanstalk .

Just remove bcrypt and start using bycryptjs

Banged my head for 2 weeks on this .

Also downgrading bcrypt to 3.0.0 won't help you with this.

Omkar Jadhav
  • 1,046
  • 3
  • 16
  • 41
6

I was able to resolve this by the following file --> .ebextensions/00_dir_permission.config. Hope this helps someone else

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_tmp_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R ec2-user /tmp
      chown -R $USER:$(id -gn $USER) /tmp/.config
      chown -R nodejs:nodejs /tmp/.npm
Lucas Crostarosa
  • 1,192
  • 6
  • 13
  • 26
6

In my case the solution with .ebextensions/00_dir_permission.config didn't work (still gave me the error), but the solution with using unsafe-perm=true in the .npmrc file did. See https://stackoverflow.com/a/46001517/769726

PS: Running on Node.js version: 8.11.4 on 64bit Amazon Linux/4.5.4

Klemens Zleptnig
  • 1,698
  • 20
  • 36
6

I solved the issue by adding a .npmrc file with

unsafe-perm=true

But adding the .npmrc to the root application folder isn't the way to go. You must specify it in a EB config file. Check out https://stackoverflow.com/a/24993093

Yoel Molinas
  • 61
  • 1
  • 1
5

Add a file named .npmrc to the application with the content:

unsafe-perm=true

Now use the following command before pushing it to ElasticBeanStalk:

git add .npmrc
git commit -m"EB issue fix"

Now deploy your code. It should work.