3
votes

I am stuck in a very weird issue from the last two days. I am trying to deploy my webpack nodejs app on AWS elastic beanstalk. The Environment Health changes from OK to Degraded. I have deployed it many times before but no such issue occurred. First of all, see the logs:

/var/log/eb-activity.log

/opt/elasticbeanstalk/containerfiles/ebnode.py --action node-install Activity execution failed, because: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install

npm ERR! path /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! code EEXIST npm ERR! Refusing to delete /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp: is outside /tmp/deployment/application/node_modules/grpc/node_modules/node-pre-gyp and not a link

npm ERR! File exists: /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! Move it away, and try again. npm ERR! A complete log of this run can be found in: npm ERR! /tmp/.npm/_logs/2018-09-18T05_49_17_967Z-debug.log Running npm install: /opt/elasticbeanstalk/node-install/node-v8.9.3-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/09/18 05:49:17 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 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.9.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)

Now the error is of some node-gyp module and trust me I haven't heard it before. I am trying for a solution so that I can continue my work because this is really an embarrassing situation for me in front of my boss. Your help can get me out of this situation.

Thanks

1
Did you solve your problem?Duda
@Duda Yes, I solved it. It was a Node Module issue. I degraded the version of that specific module and it works!!!Usman

1 Answers

4
votes

I had the same problems with various node modules. It was a simple toy project were I created the initial NodeJs express project using express init.

I found various posts about adding a file to the .ebextensions folder and ended up with this version:

Create a file called 01_delete_node_modules.config in the .ebextensions folder and add the following content:

files: "/opt/elasticbeanstalk/hooks/appdeploy/pre/49_delete_node_modules.sh": mode: "000755" owner: root group: root content: | #!/usr/bin/env bash sudo rm -rf /tmp/deployment/application/node_modules

Cudos to this blog post by Josh Harris: https://medium.com/@jharris.sf/npm-rebuild-elastic-beanstalk-and-permissions-be1c6fceba9a