I had an AWS Elastic Beanstalk node.js application not starting in one environment but would in the other environments. I typically have 3 or more environments for a service setup: localhost, dev, staging and prod. I deploy a build using <git commit #>.zip to dev after testing on my local machine. If all seems well I deploy up the environment chain until it is finally deployed in production.
The build worked on my machine and one other environment but not the next one in the progression? How can this happen? Well I’m here to tell you . . .
I had in an earlier build had the package “Q” (promises) as part of the project for one source file. It was built and deployed early in the project’s life. Later on that source and dependency was removed.
Many builds later the dependency for package “Q” was added back into the project. Unfortunately I forgot to add it to bundledDependencies in package.json so it was not included in the zip file used for deployment. Also, the staging environment was rebuilt to change the EC2 instance sizes.
So here is what happened. Package “Q” was already installed from an earlier build on the dev environment but was wiped out on the staging environment because the instances were rebuilt. When the build was deployed to staging the environment did not have “Q” package. The result is the build would not start due to a missing dependency.
Your project package.json may miss a bundledDependancies package that may have existed in an earlier build. To ensure you package.json is correct, go to one of the test environment on AWS Elastic Beanstalk and click “Rebuild Environment” and retest.