Node.js app won't deploy to AWS Elastic BeanStalk, possibly due to a lack of PostgreSQL installation
We have the following package.json file:
{
"name" : "DecisionsConsole",
"version" : "0.0.0",
"private" : true,
"scripts" : {
"start" : "node app.js"
},
"dependencies" : {
"express" : "4.0.0",
"cookie-parser" : "1.1.0",
"serve-favicon" : "2.0.0",
"morgan" : "1.1.1",
"body-parser" : "1.3.0",
"express-session" : "1.2.1",
"errorhandler" : "1.0.1",
"ejs" : "1.0.0",
"request" : "2.34.0",
"async" : "0.4.0",
"lodash" : "2.4.1",
"socket.io" : "1.0.4",
"moment" : "~2.5.1",
"pg" : "2.11.1",
"connect" : "2.14.3",
"sql" : "0.37.0",
"request-json" : "0.4.10",
"simplesets" : "1.2.0",
"grunt" : "0.4.4",
"aws-sdk" : "2.0.0-rc.19",
"webworker-threads" : "0.4.13",
"indexof" : "*",
"serve-index" : "1.6.1",
"node-rest-client" : "0.8.0",
"querystring" : "0.2.0",
"xml2js" : "0.4.6",
"msexcel-builder" : "0.0.2",
"mime" : "1.3.4"
},
"devDependencies" : {
"grunt-contrib-compress" : "~0.7.0",
"grunt-contrib-compass" : "~0.7.2",
"grunt-contrib-uglify" : "*",
"nodeunit" : "*"
}
}
We are using AWS Elastic BeanStalk framework based on 64-bit Amazon Linux 2014.02 v1.0.1 with Node.js. The reason this is an older environment and not one of the more recent versions is because there seem to be conflicts between some of our packages and the new AWS environment.
When deploying, we get the error Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.
Upon further investigation, we find such errors in eb-tools.log
:
/bin/sh: pg_config: command not found gyp: Call to 'pg_config --libdir' returned
exit status 127. gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with
exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/opt/elasticbeanstalk/node-
install/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/
configure.js:337:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:
98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:
797:12) gyp ERR! System Linux 3.4.73-64.112.amzn1.x86_64 gyp ERR! command "node" "/
opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/lib/node_modules/npm/
node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /tmp/deployment/
application/node_modules/pg gyp ERR! node -v v0.10.26 gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok > webworker-threads@0.4.13 install /tmp/deployment/application/
node_modules/webworker-threads > node-gyp rebuild make: Entering directory `/tmp/
deployment/application/node_modules/webworker-threads/build' CXX(target) Release/
obj.target/WebWorkerThreads/src/WebWorkerThreads.o
I realize this is a little tricky to read, but it's all on one line in the file eb-tools.log
. After some digging, I found this:
Error installing node-gyp on ubuntu . However, I don't think this is related.
After further research, I found the following: https://github.com/brianc/node-postgres/issues/684
This seems to make sense. The question is, how do I get AWS Elastic BeanStalk to automatically install PG?
source to share
This shows that you don't have postgres installed on an elastic fanned beanstalk instance
- Create a folder
.ebextensions
from the root of your project. -
Create a file with
package.config
and followingpackages: yum: postgresql93-devel: []
- Then commit your changes
- Finally, unfold the elastic bean stock with
eb deploy
Then you should be fine.
Check out this link for more http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html
source to share