Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Beanstalk deployment failure, permission denied, mkdir

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.  
> [email protected] 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 [email protected] 
and [email protected] (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

like image 526
Lucas Crostarosa Avatar asked Apr 21 '18 00:04

Lucas Crostarosa


1 Answers

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.

like image 53
Akash Gangrade Avatar answered Sep 20 '22 13:09

Akash Gangrade