eb-fix-npm
eb-fix-npm copied to clipboard
Deployment broken
When I try to deploy a new version of my app, I get this error from Elastic Beanstalk :
Command failed on instance. Return code: 1
Output: ln: failed to create symbolic link ‘/tmp/deployment/application/node_modules’: File exists.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/46cache_node_modules.sh failed.
For more detail, check /var/log/eb-activity.log using console or EB CLI.
Did I miss something ?
Hm, it looks like the Elastic Beanstalk staging directory (/tmp/deployment/application/
) is unclean for some reason. What version of the EB Node.js platform do you use and what are the contents of /opt/elasticbeanstalk/hooks/appdeploy/pre/
on one of your EC2 instances? I wonder if in a newer version of the EB platform, EB installs the node modules earlier than 50npm.sh
.
Also if you run this script on a fresh EC2 instance (by terminating one of the instances in your application), does it work then?
Platform version : 4.3.0
Content of directory (without eb-fix-npm) :
01_configure_xray.sh 10clean.sh 20unzip.sh 30config_clean.sh 40install_node.sh 50npm.sh 60config_generate.sh
It works the first time, yes. But if I try to update an existing instance it does not.
Ok, my next move to debug this would be to check if, when you get the "/tmp/deployment/application/node_modules
exists" error, /tmp/deployment/application/node_modules
is a regular folder or already somehow is the symlink to /var/node_modules
as initialized here. It might be that EB reuses the staging directory somehow on platform 4.3.0, and so that line needs to check whether the symlink exists already or not.
By the way, this module probably needs to be updated in other ways for platform 4.3.0. For instance, if you're using Node 8.x, thus npm 5, it might be that you no longer need to downgrade to npm 2 for speed reasons.
A disclaimer that's at the top of the README but I should repeat here: Mixmax no longer uses this module in favor of eb-disable-npm.
@xurei @wearhere any update on the issue? having same trouble here
ended up in a lot of EB pain.
for anyone struggling, removing cached modules and setting up aws codepipeline helped
@rkrasiuk could you please explain how to do this?
@dblythy well, i couldn't get direct deployment to work, so i set up aws codepipeline - webhook for github -> aws codebuild -> deployment to eb. hope that helps you!